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.
我有一张如下表
顾客 ID 1 月 2 月 3 月 4 月 ...... 12 月 1 10 12 12 10 .........40 2 11 13 12 10 .........42
我想编写 Linq 表达式以按 total(jan+feb...dec) desc 返回 order 我想要类似customers.OrderbyDesc(p=>Sum(p.jan,p.feb,.p.dec).
customers.OrderbyDesc(p=>Sum(p.jan,p.feb,.p.dec)
注意:最后没有总计栏。 如果有一种方法可以将总和投影到临时变量中然后对其进行排序?
当然 - 类似:
var ordered = customers.OrderByDescending(p => p.jan + p.feb + p.mar + ...);
你不需要在Sum这里使用......只是正常的添加。
Sum