我想按位置ID和sdmaterial计算生产和分组,但是它的错误
Prodution = productionLala.Where(n => n.Date >= x.StartDate && n.Date < x.EndDate)
.GroupBy(n => n.From_Location_ID && n.SDMaterial_Group)
.Select(n.production).Count();
有人能帮帮我吗? :) thx
答案 0 :(得分:1)
尝试这可能会有效 -
var Prodution = productionLala.Where(n => n.Date >= x.StartDate && n.Date <
x.EndDate).GroupBy(x => new{ x.From_Location_ID , x.SDMaterial_Group})
.Select(n.production).count();
答案 1 :(得分:1)
是否要为Count
和From_Location_ID
检索SDMaterial_Group
。
var groupCounts = productionLala.Where(n => n.Date >= x.StartDate && n.Date < x.EndDate)
.GroupBy(x => new
{
x.From_Location_ID,
x.SDMaterial_Group
})
.Select(x => new
{
From_Location_ID = x.Key.From_Location_ID,
SDMaterial_Group = x.Key.SDMaterial_Group,
Count = x.Count()
});