Our entities include string fields, and we're attempting to use the "LIKE" operator in Entity Framework, but it doesn't seem to be supported. Has anybody else attempted to do this?
This blog entry encapsulates the problem we're experiencing. We could use contains, but it only works for the simplest LIKE scenario. We can get there by combining contains, startswith, endswith, and indexof, but doing so involves translating common wildcards into Linq to Entities code.
The SqlFunctions.PatIndex method, which is applicable to all legal text and character data types, returns the beginning position of the first instance of a pattern in a given expression, or zeros if the pattern is not found.
Objects.Data.System is the namespace. Assembly for SQL: System.Data.Entity (in System.Data.Entity.dll)
There is also some explanation in this forum post.
I don't really know much about EF, however with LINQ to SQL, a LIKE clause is often expressed using String. Contains:
is equivalent to
WHERE Name LIKE '%xyz%'
for different actions.)
Because I don't understand what you mean when you state that you're attempting to implement LIKE, I'm not completely sure whether that is helpful. Please let me know if I entirely misunderstood, and I'll remove this response.