• 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                    
                              .Join(db.PersonExceptions,                          
                              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)                    
                              .ToList();

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

Thanks.
0
newbieweb
Asked:
newbieweb
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!
0
 
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".
0
 
newbiewebSr. Software EngineerAuthor Commented:
Thanks.
0
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