LinQ to Entities, Max Date Field, Grouped By whatever

/ Published in: C#
Save to your folder(s)

Copy this code and paste it in your HTML
  1. from p in PersonOrders
  2. // put your where clause here
  3. group p by p.PersonID into grp //could be grouped by anything, Grouping on Guid ID's is not a good idea
  4. let MaxOrderDatePerPerson = grp.Max ( g=>g.OrderDate )
  6. from p in grp
  7. where p.OrderDate == MaxOrderDatePerPerson
  8. select p


Report this snippet


RSS Icon Subscribe to comments

You need to login to post a comment.