How to implement SQL “in” in Entity framework 4.0

后端 未结 2 1315
礼貌的吻别
礼貌的吻别 2020-12-18 04:32

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 use         


        
相关标签:
2条回答
  • 2020-12-18 04:43

    Try this:

    var identifiers = new[] { 1, 2, 3, 4 };
    var users = from e in context.Users where identifiers.Contains(e.UserId);
    
    0 讨论(0)
  • 2020-12-18 04:54
    var users = from e in context.Users where idList.Contains(e.UserId)
    
    0 讨论(0)
提交回复
热议问题