EF记录最大值(按值)
本文关键字:按值 最大值 记录 EF | 更新日期: 2023-09-27 17:58:54
我想获得基于字段的最大记录,但Max()扩展返回给定的类型。这样说:
o.Max(i => i.CreatedDate) // returns date
返回最大日期值;我想像一样返回记录本身
o.Max(i => i.CreatedDate) // returns the record with the maximum condition
有办法做到这一点吗?
谢谢。
o.OrderByDescending(i => i.CreatedDate).First()