0
有人可以幫助我與下面的Linq聲明?我試圖通過Linq,通過最後一個表加入4個表,並總結第一個屬性。Linq總結多個聯接
var payments = (
from payment in db.Payments
join payees in db.cmsMembers on payment.PayeeID equals payees.nodeId
join payeeGroups in db.cmsMember2MemberGroups on payees.nodeId equals payeeGroups.Member
join groups in db.umbracoNodes on payeeGroups.MemberGroup equals groups.id
group groups by new {groups.text, payment} into groupedPayments
select new
{
Group = groupedPayments.Key.text,
Count = groupedPayments.Count(),
Amount = groupedPayments.Sum(?)
}
).ToList();
我遇到的問題是,在groupedPayments.Sum(..)調用我只能夠訪問這些「組」對象。對於組名稱和計數方面而言,這很好,但必須在payment.Amount屬性上執行SUM。
嘿,groupedPayments.Sum(i => i.payment)不起作用? –