2010-06-04 3 views
5

So implementieren Sie die folgende Abfrage von SQL in Entity-Framework. SELECT * FROM Users WHERE UserID in (1,2,3,4).So implementieren Sie SQL "in" in Entity-Framework 4.0

ich, dies zu tun versuchen

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

Dank Ashwani

+0

möglich Duplikat [Linq to Entities - Sql "IN" Klausel] (http://stackoverflow.com/questions/857973/linq-to-entities-sql-in-clause) –

Antwort

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

Versuchen:

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