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

c# entity-framework

Question

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

I'm attempting to

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

Do 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