so.. I'm using LinqToEntities, and I want to query part of a field. Normally I'd use the LIKE keyword with SQL, and then go from there..
I see that Linq does not have it.. Whats a good way to get the same kind of functionality?
You can use String.StartsWith()
or String.Contains()
.
For example:
var query = from b in db.Books
where b.Title.Contains("time")
select b;
This works because LINQ turns the query into an expression tree, and for LINQ to SQL/Entities, many "standard" C# methods are supported for the conversion to SQL.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With