max date record in LINQ

后端 未结 6 1306
一个人的身影
一个人的身影 2021-02-03 21:35

I have this table named sample with these values in MS Sql Server:

 ID    Date    Description
1    2012/01/02 5:12:43    Desc1
2    2012/01/02 5:12:48    Desc2
3         


        
6条回答
  •  终归单人心
    2021-02-03 22:18

    List q = Sample.OrderByDescending(T=>T.Date).Take(1).ToList();
    

    But I think you want

    Sample q = Sample.OrderByDescending(T=>T.Date).FirstOrDefault();
    

提交回复
热议问题