LINQ Join 2 List<T>s

Posted by David Murdoch on Stack Overflow See other posts from Stack Overflow or by David Murdoch
Published on 2010-04-27T18:40:24Z Indexed on 2010/04/27 18:43 UTC
Read the original article Hit count: 312

Filed under:
|
|

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 lists that I need to join together:

// contains ALL contacts for a customer.
// Each item has a unique ID.
// There are no duplicates.
ContactCollection list1 = myCustomer.GetContacts();

// contains the customer contacts (in list1) relevant to a REPORT
// the items in this list may have properties that differ from those in list1.
/*****/// e.g.:
/*****/        bool SelectedForNotification; 
/*****///  may be different.
ContactCollection list2 = myReport.GetContacts();

I need to create a third ContactCollection that contains all of the contacts in list1 but with the properties of the items in list2, if they are there (list3.Count == list1.Count).

I feel as though I'm not making any sense. So, please ask questions in the comments and I'll try to clarify.

© Stack Overflow or respective owner

Related posts about LINQ

Related posts about c#3.0