开发者

EF Max on Record By Value

开发者 https://www.devze.com 2023-03-12 02:58 出处:网络
I want to get the maximum record based on a field, but the Max() extension returns that given type.Say this:

I want to get the maximum record based on a field, but the Max() extension returns that given type. Say this:

o.Max(i => i.CreatedDate) // returns date

Returns the maximum date value; I want to return the record itself like:

o.Max(i => i.CreatedDate) // returns the record with the ma开发者_JAVA百科ximum condition

Is there a method to do this?

Thanks.


o.OrderByDescending(i => i.CreatedDate).First()
0

精彩评论

暂无评论...
验证码 换一张
取 消