すべての子オブジェクトの合計を取得するために、ループごとに次のものがあります。LINQを使用するより良い方法はありますか?
Purchase p1 = db.Purchases.FirstOrDefault(p => p.PurchaseId == 1);
int total = 0;
foreach (SellingItem item in p1.SellingItems)
{
total = total + Convert.ToInt32(item.Price);
}
参照: