Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 746503
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T14:05:55+00:00 2026-05-14T14:05:55+00:00

Preface: I don’t understand what this does: o => o.ID, i => i.ID, (o,

  • 0

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:

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

// list2 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 the item is in the list[2] (list3.Count == list1.Count).


I need to replace all items in list1 with the items in list2 where items in list1 have the IDs of the items in list2. The resulting list (list3) should contain the same number of items at list1.

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T14:05:55+00:00Added an answer on May 14, 2026 at 2:05 pm

    Joins are not so difficult, but your problem could probably use some further explanation.

    To join two lists, you could do something like

    var joined = from Item1 in list1
                 join Item2 in list2
                 on Item1.Id equals Item2.Id // join on some property
                 select new { Item1, Item2 };
    

    this will give an IEnumerable<'a>, where ‘a is an anonymous type holding an item from list1 and its related item from list2. You could then choose which objects’ properties to use as needed.

    To get the result to a concrete list, all that is needed is a call to .ToList(). You can do that like

    var list3 = joined.ToList();
    // or
    var list3 = (from Item1 in list1
                 join Item2 in list2
                 on Item1.Id equals Item2.Id // join on some property
                 select new { Item1, Item2 }).ToList();
    

    To do a left join to select all elements from list1 even without a match in list2, you can do something like this

    var list3 = (from Item1 in list1
                 join Item2 in list2
                 on Item1.Id equals Item2.Id // join on some property
                 into grouping
                 from Item2 in grouping.DefaultIfEmpty()
                 select new { Item1, Item2 }).ToList();
    

    This will give you a list where Item1 equals the item from the first list and Item2 will either equal the matching item from the second list or the default, which will be null for a reference type.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have to preface this with the fact that I love jQuery as a
I'll preface this by saying that I usually work in C#/.Net. Normally, I use
Just to preface: I work in a small company that does ASP.NET development and
Preface: I don't have experience with rules engines, building rules, modeling rules, implementing data
I'd like to preface this by stating that this is for a class, so
We are using WSS 3 SP2. I'd like to preface this by saying that
I'll preface this question by mentioning that while I'm far from a regular expressions
Let me preface this by saying that I'm a very raw iPhone developer. I'm
This is a C# winforms app. Preface: I am creating a form that will
To preface I am using Borland C++ and the VCL. I need some sort

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.