[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Question about Join and LINQ

Posted on 2012-08-16
3
Medium Priority
?
430 Views
Last Modified: 2012-08-19
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
Comment
Question by:newbieweb
3 Comments
 
LVL 20

Assisted Solution

by:Rikin Shah
Rikin Shah earned 800 total points
ID: 38301618
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
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 1200 total points
ID: 38301797
"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
 

Author Closing Comment

by:newbieweb
ID: 38310272
Thanks.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question