compare two list and return not matching items using linq

后端 未结 10 548
死守一世寂寞
死守一世寂寞 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:01

    You can do like this,this is the quickest process

    Var result = MsgList.Except(MsgList.Where(o => SentList.Select(s => s.MsgID).ToList().Contains(o.MsgID))).ToList();
    

    This will give you expected output.

提交回复
热议问题