Linq to Entities - SQL “IN” clause

前端 未结 8 1247
被撕碎了的回忆
被撕碎了的回忆 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();
    
    0 讨论(0)
  • 2020-11-22 06:11

    Seriously? You folks have never used

    where (t.MyTableId == 1 || t.MyTableId == 2 || t.MyTableId == 3)
    
    0 讨论(0)
提交回复
热议问题