我有c#返回2个日期的数据列表。
5/31/2016 4:34:41 AM
5/31/2016 4:38:08 AM
我正在使用lambda表达式对它们进行排序以显示最新日期。但它仍显示错误。可能是什么问题。
var rowEntities =
MyOperations.GetEntitiesByDate().ToList().OrderByDescending(i=>i.JobStartTime);
public DateTime JobStartTime { get; set; }
答案 0 :(得分:1)
var rowEntities = MyOperations.GetEntitiesByDate().ToList().OrderByDescending(i=>i.JobStartTime);
或
var rowEntities = (from dates in MyOperations.GetEntitiesByDate() orderby dates.jobstarttime select dates).Tolist();
或
var rowEntities = (from dates in MyOperations.GetEntitiesByDate() orderby dates.jobstarttime ascending or descending select dates).Tolist();
答案 1 :(得分:1)
尝试
var rowEntities = MyOperations.GetEntitiesByDate().OrderByDescending(i=>i.JobStartTime).ToList();