2010-06-07 63 views
0

我有如下的类:LINQ到基于组总结两列

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)) 

但是,这并不工作,因为我不能在两列组。

有什么建议吗?

回答

2
... 
group operation by new { operation.Debit, operation.Credit } into groupedOperation 
...