Using LINQ to Objects to find items in one collection that do not match another

后端 未结 8 1886
清酒与你
清酒与你 2020-12-29 05:04

I want to find all items in one collection that do not match another collection. The collections are not of the same type, though; I want to write a lambda expression to spe

8条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-29 05:59

    var nonmanagers = employees.Select(e => e.Id)
        .Except(managers.Select(m => m.EmployeeId))
        .Select(id => employees.Single(e => e.Id == id));
    

提交回复
热议问题