Possible Duplicate:
How to do SQL Like % in Linq?
Like Operator in Entity Framework?
I'm doing a query like this:
var matches = from m in db.Customers
where m.Name == key
select m;
But I don't need m.Name
to be exactly equal to key. I need m.Name
to be like key.
I can't find how to recreate the SQL query:
WHERE m.Name LIKE key
I'm using SQL Server 2008 R2.
How to do it?
Thanks.
Would something like this linq query work for you.. ?
var matches = from m in db.Customers
where m.Name.Contains(key)
select m;
this should also work I edited my answer.
Contains
is mapped to LIKE '%@p0%' which is case insensitive