• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 434
  • Last Modified:

Question about Join and LINQ

Please explain the fourth element contained in the Join?

List<Person> pr = db.Persons                    
                              p => p.ID,                          
                              e => e.PersonID,                          
                              (p, e) => new { p, e })                    
                              .Where(z => z.e.CreatedOn >= fromDate)                    
                              .OrderByDescending(z => z.e.CreatedOn)                    
                              .Select(z => z.p)                    

Is this line:
(p, e) => new { p, e })                    
just creating a new table that is the product of the two other tables?

2 Solutions
Rikin ShahMicrosoft Dynamics CRM ConsultantCommented:
Create a list of p-e pairs where  
each element is an anonymous type that contains a
P's name and the name of the P that owns the e.

Hope this helps!
käµfm³d 👽Commented:
"p" is the element from the outer IEnumerable--each item in Persons. "e" is the element from the inner IEnumerable--each item in PersonExceptions. The net effect is that wherever an element from each IEnumerable is equal to other by the appropriate keys, you get access to both elements--one in the "p" and the other in the "e".
newbiewebSr. Software EngineerAuthor Commented:
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now