Search code examples
c#.netsqllinqlinq-to-entities

LIKE with Linq to Entities


I know the .Contains() method does like LIKE %therm%, the .StartsWith() method does like LIKE therm% and the .EndsWith() method like LIKE %therm but...

Is there a way to do like below on **Linq to Entities**?

SELECT * FROM [dbo].[Users] WHERE Name LIKE 'rodrigo%otavio%diniz%waltenberg'

PS: I'M USING LINQ TO ENTITIES. NOT LINQ TO SQL


Solution

  • Yes, you can do this with ESQL/Query Builder syntax:

    var matching = Context.Users.Where("it.Name LIKE 'rodrigo%otavio%diniz%waltenberg'");