2010-06-07 4 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 
... 
관련 문제