linq查询以list <int>条件进行过滤

时间:2018-10-02 06:16:05

标签: entity-framework linq

我有一个从数据表发送来的int列表,我需要用这个对象过滤整个列表。

var Ids = new List<int>();  
Ids = {2, 4, 5};

var result = (from m in member
                     join r in role on m.memberId equals r.memberId
                     where
                         Ids.Equals(m.memberId) && r.status = 1
                     select m).ToList();

我很想在单个查询中获得结果。

1 个答案:

答案 0 :(得分:0)

我解决了这个问题

var Ids = new List<int>();  
Ids = {2, 4, 5};

var result = (from m in member
                     join r in role on m.memberId equals r.memberId
                     where
                         Ids.Any(i=> i == m.memberId) && r.status = 1
                     select m).ToList();