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.
我有以下 LINQ 查询,用于对所有员工进行分组。
var groups = from employee in employees group employee by employee.ReportsTo;
该链接返回一个 IGrouping 对象。
我现在想使用 ReportsTo 订购此结果,其中 ReportsTo 是每个员工的经理的姓名。如何使用 C# 实现这一点?这可能吗?
var groups = from employee in employees group employee by employee.ReportsTo into g orderby g.Key select g;
我宁愿这样写,因为它更“可读”
var groups = employees.GroupBy(employee => employee.ReportsTo).OrderBy(group => group.Key)