Linq LIKE functionality

therefore, I am using LinqToEntities, and I want to query for part of the field. Normally I would use the LIKE keyword with SQL and then from there ..

I see that Linq does not have this. How can I get the same functionality?

+4
source share
1 answer

You can use String.StartsWith() or String.Contains() .

For instance:

 var query = from b in db.Books where b.Title.Contains("time") select b; 

This works because LINQ turns a query into an expression tree, and for LINQ to SQL / Entities, many of the "standard" C # methods are supported for conversion to SQL.

+8
source

Source: https://habr.com/ru/post/1311746/


All Articles