Is there a “not equal” in a linq join

后端 未结 4 2253
孤街浪徒
孤街浪徒 2020-12-05 04:27

I am trying accomplish the LINQ query below but I need a \"not equal\" instead of equal, so that filteredEmployees has all employees from groupA minus groupB.



        
4条回答
  •  [愿得一人]
    2020-12-05 05:05

    In Entity Framework 6, I've gotten better results using

    var filteredEmployees = groupA.Where(a => !groupB.Select(b => b.Name).Contains(a.Name));
    

提交回复
热议问题