Reputation: 16960
Going backwards from SQL to LINQ2SQL is sometimes quite simple. The following statement
SELECT user FROM users WHERE lastname='jones'
translates fairly easily into
from u in users where u.lastname='jones' select u
But how do you get the following SQL generated?
SELECT user FROM users WHERE lastname IN ('jones', 'anderson')
Upvotes: 9
Views: 1723
Reputation: 16960
I had to do a bit of searching to find this, and thought it might be useful to others.
List<string> names = new List<string>() { "jones", "anderson" };
from u in users where names.Contains(u.lastname) select u
Upvotes: 13