5
如何在实体框架中实现以下SQL查询。 SELECT * FROM Users WHERE UserID in (1,2,3,4)
。如何在实体框架4.0中实现SQL“in”
我试图做
var users = from e in context.Users where e.UserId in (list of user ids)
感谢 Ashwani
如何在实体框架中实现以下SQL查询。 SELECT * FROM Users WHERE UserID in (1,2,3,4)
。如何在实体框架4.0中实现SQL“in”
我试图做
var users = from e in context.Users where e.UserId in (list of user ids)
感谢 Ashwani
var users = from e in context.Users where idList.Contains(e.UserId)
试试这个:
var identifiers = new[] { 1, 2, 3, 4 };
var users = from e in context.Users where identifiers.Contains(e.UserId);
的
可能重复[LINQ到实体 - SQL “IN” 的条款( http://stackoverflow.com/questions/857973/linq-to-entities-sql-in-clause) – 2014-03-24 08:20:22