How to select only the records with the highest date in LINQ

前端 未结 5 1150
一向
一向 2020-11-28 03:15

I have a table, \'lasttraces\', with the following fields.

Id, AccountId, Version, DownloadNo, Date

The data looks like this:



        
5条回答
  •  感动是毒
    2020-11-28 03:55

    It could be something like:

    var qry = from t in db.Lasttraces
              group t by t.AccountId into g
              orderby t.Date
              select new { g.AccountId, Date = g.Max(e => e.Date) };
    

提交回复
热议问题