I have a case in my application where the user can search for a list of terms. The search needs to make three passes in the following order:
- One for an exact match of what they entered. Done, easy.
- One where all the words (individually) match. Done, also easy.
- One where any of the words match…how?
Essentially, how do I, in Linq to Sql, tell it to do this:
select * from stuff s where s.Title like '%blah%' || s.Title like '%woo&' || s.Title like '%fghwgads%' || s.Title like...
And so on?
This might be a tough one… I think you’d have to write your own operator.
(Update: Yep, I tested it, it works.)
Then you could call this with:
P.S. You’ll need to add the
System.Linq.ExpressionsandSystem.Data.Linq.SqlClientnamespaces to your namespaces for theQueryExtensionsclass.