我有以下LINQ查询:
summaries = from m in _master
join d in _detail on pk + m.RowKey equals d.PartitionKey into outer
from d in outer.DefaultIfEmpty()
select new
{
Position = m.Position,
Title = m.Title,
Detail = ((d == null) ? 0 : 1),
PartitionKey = m.PartitionKey,
RowKey = m.RowKey,
Modified = m.Modified,
ModifiedBy = m.ModifiedBy
} into split
group split by split.Title into g
select new AdminSummary
{
Position = g.Last().Position,
Title = g.Key,
DetailCount = g.Sum(s => s.Detail),
PartitionKey = g.Last().PartitionKey,
RowKey = g.Last().RowKey,
Modified = g.Last().Modified,
ModifiedBy = g.Last().ModifiedBy
};
查询运行良好,但现在我想通过位置(双)跟随标题(字符串)进行排序。
有人可以建议我怎么做吗?
有人能告诉我怎么做订单吗?
答案 0 :(得分:2)
这很简单:
summaries = summaries.OrderBy(item =>item.Position).ThenBy(item =>item.Title);
如果您需要按降序排列,也可以使用OrderByDescending()
和ThenByDescending()
答案 1 :(得分:1)
在上述查询后执行此操作。
summaries = from s in summaries
orderby s.Position,s.Title
select s