Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wildcard search for LINQ

I would like to know if it is possible to do a wildcard search using LINQ.

I see LINQ has Contains, StartsWith, EndsWith, etc.

What if I want something like %Test if%it work%, how do I do it?

Regards

like image 395
PlayKid Avatar asked Jun 24 '09 19:06

PlayKid


1 Answers

You can use SqlMethods.Like().

An example of the usage:

var results =         from u in users         where SqlMethods.Like(u.FirstName, "%John%")         select u; 
like image 83
Ryan Versaw Avatar answered Oct 10 '22 16:10

Ryan Versaw