Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有代码,我正在从我的表中查询一些东西,该表有一个名为CreateDate. 我只想获取最近日期的对象。这就是我所拥有的:
CreateDate
var post = UnitOfWork.TableName.Query(postFilter);
我尝试使用这样的 Max 函数:
var post = UnitOfWork.TableName.Query(postFilter).Max(x => x.CreatedDate);
但这仅返回日期。
如何返回最新的整个对象?
您必须按日期订购并取一份:
var post = UnitOfWork.TableName.Query(postFilter) .OrderByDescending(x => x.CreatedDate) .FirstOrDefault();