我有这个问题:
from e in Employee
join t in TimeTable
on e.Id equals t.EmpId
group new {e,t} by e.Id into g
orderby g.Key
select new
{
Emp = g.Key,
Items = g.Select(c => c.t.OtherTable.Somevalue).Distinct()
}
它工作正常,但我需要撤消分组,以便将所有Employees
分组到OtherTable.Somevalue
我该怎么做?
答案 0 :(得分:2)
可能会喜欢这样,它会起作用
from e in Employee
join t in TimeTable
on e.Id equals t.EmpId
group new {e,t} by t.OtherTable.Somevalue into g
orderby g.Key
select new
{
SomeValue = g.Key,
Emplyees = g.Select(c => c.e.Id).Distinct()
}