Select most recent records using LINQ to Entities

Posted by begemotya on Stack Overflow See other posts from Stack Overflow or by begemotya
Published on 2010-05-03T20:46:08Z Indexed on 2010/05/03 20:48 UTC
Read the original article Hit count: 334

Filed under:
|
|

I have a simple Linq to Enities table to query and get the most recent records using Date field

So I tried this code:

IQueryable<Alert> alerts = GetAlerts(); IQueryable latestAlerts = from a in alerts group a by a.UpdateDateTime into g select g.OrderBy(a => a.Identifier).First();

Error: NotSupportedException: The method 'GroupBy' is not supported.

Is there any other way to get do it? Thanks a lot!

© Stack Overflow or respective owner

Related posts about c#

Related posts about LINQ