如何合并这两位代码

时间:2012-08-20 14:42:34

标签: c# linq

如何将这两位代码转换为一位?

comCtrList = (from i in genOutList
                                  join f in genAccList
                                          on i.Contract equals f.Contract
                                  select i.Contract).ToList();

genOutList.RemoveAll(acc => comCtrList.Contains(acc.Contract));

1 个答案:

答案 0 :(得分:0)

你想要这样的东西吗?

genOutList= (
                  from i in genOutList
                  where !genAccList.Any(x=>x.Contract==i.Contract)
                  select i
             ).ToList();

或者

genOutList.RemoveAll(x=>genAccList.Any(i=>i.Contract==x.Contract));