2011-06-12 42 views
1

我想根據字段獲取最大記錄,但Max()擴展返回給定類型。說這個:EF Max按值記錄

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

返回最大日期值;我想要返回記錄本身,如:

o.Max(i => i.CreatedDate) // returns the record with the maximum condition 

有沒有一種方法可以做到這一點?

謝謝。

回答

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