AddRange Linq查询之前的OrderByDescending

时间:2017-04-18 09:44:42

标签: c# linq

我有两个Listpromolistpackagelistpackagelist数据必须是第一个packagelistlist必须OrderByDescendingThenByDescending level然后totalclick

贝娄是我试过的

promolist.OrderByDescending(o =>  o.packagelevel.level).ThenByDescending(o => o.totalclick);
promolist.AddRange(packagelist.OrderByDescending(o => o.packagelevel.level).ThenByDescending(o => o.totalclick));
return promolist;

结果几乎是我想要的,promolistpackagelist之前,packagelist正确排序,只有 promolist没有做任何{{1 }或OrderByDescending

1 个答案:

答案 0 :(得分:2)

OrderBy的结果是您需要分配和评估的新枚举。你不会对结果做任何事情。

你需要这个:

promolist = promolist.OrderByDescending(o =>  o.packagelevel.level)
                     .ThenByDescending(o => o.totalclick)
                     .ToList();