var r = from l in Model.BankStatement_ItemSouce
where(l.STATUS==8)
group l by l.DOCUMENT_NO into g
select new { DOCUMENT_NO = g.Key,STATUS=g.Key, AMOUNT_RECEIVABLE =g.Where(t=>t.STATUS==8).Average(t => t.AMOUNT_RECEIVABLE), PRIJECT_VALUE=g.Sum(t=>t.PRIJECT_VALUE),ARREARS=g.Average(t=>t.ARREARS)};
foreach (var item in r)
{
Model.AmountCount = item.AMOUNT_RECEIVABLE + Model.AmountCount;//应收总金额
Model.ForegiftCount = item.PRIJECT_VALUE + Model.ForegiftCount;//实收总金额
Model.ArrearsCount = item.ARREARS + Model.ArrearsCount; //欠款总金额
}
PS:开始要把AmountCount,ForegiftCount,ArrearsCount初始化为0.decimal类型。