複数のフィールドでグループ化しようとしましたが、問題が発生しています。ピリオド、プロダクトコードでグループ化したいlinqを使用して複数のグループにグループ化する
var ProductUsageSummary = from b in myProductUsage
group b by b.ProductCode into g
select new
{
Period = g.Key,
Code = g.Key,
Count = g.Count(),
TotalQty = g.Sum(n => n.Qty),
Price = g.Average(n => n.Price)
};
もあなたが複数の列(EX ... new {prop1 prop2}
)上のグループへのanonymounsオブジェクトを作成することができ、およびグループ化されたフィールドはKey.PropertyName
てみによってアクセスすることができ
var ProductUsageSummary = from b in myProductUsage
group b by b.Period b.ProductCode into g
select new
{
Period = g.Key(n => n.period),
Code = g.Key,
Count = g.Count(),
TotalQty = g.Sum(n => n.Qty),
Price = g.Average(n => n.Price)
};