Return to Snippet

Revision: 51897
at October 6, 2011 23:59 by Krummelz


Initial Code
from p in PersonOrders
// put your where clause here
group p by p.PersonID into grp //could be grouped by anything, Grouping on Guid ID's is not a good idea
let MaxOrderDatePerPerson = grp.Max ( g=>g.OrderDate )
 
from p in grp
where p.OrderDate == MaxOrderDatePerPerson
select p

Initial URL
http://smehrozalam.wordpress.com/2009/12/29/linq-how-to-get-the-latest-last-record-with-a-group-by-clause/

Initial Description

                                

Initial Title
LinQ to Entities, Max Date Field, Grouped By whatever

Initial Tags
date

Initial Language
C#