Linq to Entities - SQL “IN” clause

前端 未结 8 1410
被撕碎了的回忆
被撕碎了的回忆 2020-11-22 05:10

In T-SQL you could have a query like:

SELECT * FROM Users WHERE User_Rights IN (\"Admin\", \"User\", \"Limited\")

How would you replicate t

8条回答
  •  生来不讨喜
    2020-11-22 05:56

    This could be the possible way in which you can directly use LINQ extension methods to check the in clause

    var result = _db.Companies.Where(c => _db.CurrentSessionVariableDetails.Select(s => s.CompanyId).Contains(c.Id)).ToList();
    

提交回复
热议问题