2010-06-04 19 views
5

Come implementare la seguente query di SQL nel framework di entità. SELECT * FROM Users WHERE UserID in (1,2,3,4).Come implementare SQL "in" in Entity framework 4.0

che sto cercando di fare

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

Grazie Ashwani

+0

possibile duplicato di [LINQ to Entities - Sql "IN" clausola] (http://stackoverflow.com/questions/857973/linq-to-entities-sql-in-clause) –

risposta

8
var users = from e in context.Users where idList.Contains(e.UserId) 
9

Prova questo:

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