Possible Duplicate:
How to do SQL Like % in Linq?
Im using mvc 3 and entity framework. How do i do a like search with linq or a lambda expression. Please assisst
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Since the goal is for EF expressions to be parsed into SQL, where the
LIKEpredicate should be applied, there are at least 3 ways to do this, depending on where you want the%wildcard to be placedStarts With the Phrase
C#:
=> SQL
Contains the Phrase
C#:
=> SQL
Ends in the Phrase
C#:
=> SQL
Performance
When applicable, for performance reasons,
StartsWithshould be preferred over the other two, given that it has a better chance of using an index on the column.LIKE %x%orLIKE %xwill generally result in an index or table scan, unless an unusual index is created on the column.