compare two list and return not matching items using linq

后端 未结 10 569
死守一世寂寞
死守一世寂寞 2021-02-01 02:52

i have a two list

List SentList;
List MsgList;

both have the same property called MsgID;

MsgList            


        
10条回答
  •  难免孤独
    2021-02-01 03:10

    Well, you already have good answers, but they're most Lambda. A more LINQ approach would be like

    var NotSentMessages =
                    from msg in MsgList
                    where !SentList.Any(x => x.MsgID == msg.MsgID)
                    select msg;
    

提交回复
热议问题