从给定的设置
IEnumerable<int> one = new int[] { 1, 2, 3, 4, 5, 6, 7 };
IEnumerable<int> two = new int[] { 12, 34, 56, 7, 8 };
MySet[] sets
= new MySet[]
{
new MySet{ MySetID =100, MySubSet=new MySubSet{SubSet=new List<int>(one),
SubSetID=1212}},
new MySet{ MySetID =101, MySubSet=new MySubSet{SubSet=new List<int>(two),
SubSetID=1414}}
};
如何从“SubSet”中过滤掉偶数
var GetSet =
from mysets in sets
where (P => mysets.MySubSet.SubSet.FindAll(???? ))
select mysets;
答案 0 :(得分:1)
var query = from mySet in sets
select new MySet {
MySetID = mySet.ID,
MySubSet = new MySubSet {
SubSet = mySet.MySubSet.SubSet.Where(p => p % 2 == 0).ToList(),
SubSetID = mySet.MySubSet.SubSetID
}
};
因此,我将您的问题解释为您希望在MySubSet.SubSet
的每个实例中过滤掉MySet
中的偶数。