C# linq我该如何订购这份声明
如您所见,我试图在语句末尾执行多个order by语句。我的结果不正确C# linq我该如何订购这份声明,c#,linq,linq-to-sql,C#,Linq,Linq To Sql,如您所见,我试图在语句末尾执行多个order by语句。我的结果不正确 var query = (from x in workloadDetail group x by new { x.titleOrder, x.httitle } into sortedData select new WorkloadSummary() { httitle = sortedData.Key.httitle, tot
var query =
(from x in workloadDetail
group x by new { x.titleOrder, x.httitle } into sortedData
select new WorkloadSummary()
{
httitle = sortedData.Key.httitle,
totalHrs = sortedData.Sum(x => x.totalHrs),
totalDol = sortedData.Sum(x => x.totalDol),
titleOrder = sortedData.Key.titleOrder
}).OrderBy(x => x.httitle).OrderByDescending(x => x.totalHrs);
使用ByDescending方法按降序应用二级排序
.OrderBy(x => x.httitle).ThenByDescending(x => x.totalHrs);
使用ByDescending方法按降序应用二级排序
.OrderBy(x => x.httitle).ThenByDescending(x => x.totalHrs);
如果要链接多个OrderBy查询,则需要使用ThenBy和ThenBy Descending作为后续属性,以便按照正确的顺序应用它们:
.OrderBy(x => x.httitle).ThenByDescending(x => x.totalHrs);
如果要链接多个OrderBy查询,则需要使用ThenBy和ThenBy Descending作为后续属性,以便按照正确的顺序应用它们:
.OrderBy(x => x.httitle).ThenByDescending(x => x.totalHrs);
我快了9秒:Pi快了9秒:P