但我无法按照上表中的DayOfWeek对数据进行分组。 这是我的代码:
from s in Shifts
where PlacementContractID == 3
select new
{
DayOfWeek = s.DayOfWeek,
EmployeesNeeded = s.NumberOfEmployees
}
答案 0 :(得分:2)
您似乎正在尝试执行以下操作:
Shifts.Where(sh => sh.PlacementContractID == 3)
.GroupBy(sh => sh.DayOfWeek)
.Select(g => new{
DayOfWeek = g.Key,
EmployeesNeeded = g.Sum(sh => sh.NumberOfEmployees) //maybe a cast required?
})
从查询语法转换为流利语法的道歉。