Is there a simple way to use LIKE in EF yet?
Like is available via passing a string through ESQL... but not as an actual operator or method anywhere so far. I've found numerous articles suggesting work-arounds, the most interesting of which I get an exc开发者_如何转开发eption on:
NotSupportedException: The specified method 'Boolean Like(System.String, System.String)' on the type 'EF4.Extensions' cannot be translated into a LINQ to Entities store expression.
Anything here yet? EF 4.1 is out... any news or clean options?
In EF 4.x, string.StartsWith, string.EndsWith, and string.Contains are translated to SQL LIKE. (Although neither support multiple wildcards...)
First of all, @KristoferA is absolutely correct concerning SqlClient.
But this functionality depends on EF Provider. For example, Devart providers for Oracle, MySQL, PostgreSQL, and SQLite contain Like calls in the StartsWith, EndsWith and Contains String methods in both EF v1 and EF v4. Other providers may not contain Like support in EF v4 as well.
精彩评论