我有一堂课如下:
Class Financial
{
string Debit;
string Credit;
decimal Amount;
}
我有一个包含此类对象的列表,其中包含多条记录。我只需要执行一个分组求和,就像在 sql
Select debit, Credit, sum(amount) group by Debit, Credit
我尝试了如下声明:
from operation in m_listOperations
orderby operation.Debit, operation.Credit ascending
group operation by operation.Debit, operation.Credit into groupedOperation
select new Financial(Debit, Credit,
groupedOperation.Sum(operation => operation.Amount))
但这不起作用,因为我不能在两列上分组。
有什么建议么?