Posted By

Krummelz on 10/06/11


Tagged

date to max field entities BY group Linq


Versions (?)

LinQ to Entities, Max Date Field, Grouped By whatever


 / Published in: C#
 

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

  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 )
  5.  
  6. from p in grp
  7. where p.OrderDate == MaxOrderDatePerPerson
  8. select p

Report this snippet  

You need to login to post a comment.