LINQ Join 2 Lists

后端 未结 4 894
感情败类
感情败类 2020-11-29 07:36

Preface: I don\'t understand what this does:

o => o.ID, i => i.ID, (o, id) => o

So go easy on me. :-)


I have 2 lis

4条回答
  •  孤独总比滥情好
    2020-11-29 07:42

    Here is what I came up with (based on this):

            List list3 = (from item1 in list1
                join item2 in list2
                on item1.ContactID equals item2.ContactID into g
                from o in g.DefaultIfEmpty()
                select o == null ? item1 :o).ToList();
    

    My favorite part is the big nosed smiley

    :o)

    Thanks for your help!

提交回复
热议问题