In Entity Framework 4.0, how do you implement SQL "in"?

c# entity-framework

Question

How to implement following query of SQL in entity framework. SELECT * FROM Users WHERE UserID in (1,2,3,4).

I am trying to do

var users = from e in context.Users where e.UserId in (list of user ids)

Thanks Ashwani

1
6
6/4/2010 11:45:13 AM

Accepted Answer

var users = from e in context.Users where idList.Contains(e.UserId)
9
6/4/2010 11:47:11 AM

Popular Answer

Try this:

var identifiers = new[] { 1, 2, 3, 4 };
var users = from e in context.Users where identifiers.Contains(e.UserId);


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow