views:

47

answers:

1

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?

+8  A: 

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.

Neil Barnwell
Awesome! Works great!
KevinDeus