Wednesday, December 03, 2008

SQL IN operator with Linq to SQL

Re: Would it be hard to add support for SQL IN (...,...) ? - MSDN Forums

There is a way to use IN parameter, or a workaround, for Linq to SQL queries. It is done in the following manner:

string[] cities = { "London", "Paris", "Seattle" };

var query = dataContext.Customers.Where (c => cities.Contains (c.City));

No comments: