0

Possible Duplicate:
How to do SQL Like % in Linq?

I am trying to implement the code below in LINQ, but still I couldn't find a way:

SELECT * FROM Persons
WHERE City LIKE '%tav%'

How can I write this in LINQ?

Community
  • 1
  • 1
Muditha
  • 167
  • 4
  • 12

1 Answers1

2

Something like this:

var query = dataContext.Person.Where(p=>p.City.Contains("tav"));

Depending on your sql server configuration you may need to compare only lower-case or upper-case letters:

var query = dataContext.Person.Where(p=>p.City.ToLower().Contains("tav"));
horgh
  • 17,918
  • 22
  • 68
  • 123