EF最大记录值按值

问题描述

| 我想获取基于字段的最大记录,但是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()