Filtering lists using LINQ

前端 未结 9 2055
暖寄归人
暖寄归人 2021-02-04 00:23

I\'ve got a list of People that are returned from an external app and I\'m creating an exclusion list in my local app to give me the option of manually removing people from the

9条回答
  •  盖世英雄少女心
    2021-02-04 00:51

    This LINQ below will generate the SQL for a left outer join and then take all of the results that don't find a match in your exclusion list.

    List filteredResults =from p in people
            join e in exclusions on p.compositeKey equals e.compositeKey into temp
            from t in temp.DefaultIfEmpty()
            where t.compositeKey == null
            select p
    

    let me know if it works!

提交回复
热议问题