views:

58

answers:

1

Hi,

I have a class as below:

Class Financial
{
    string Debit;
    string Credit;
    decimal Amount;
}

And I have a list with objects of this class, with multiple records. All I need is to perform a groupped sum, something like in sql

Select debit, Credit, sum(amount) group by Debit, Credit

I tried with a statement as below:

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

But this don't works since I cannot group on two columns

Any suggestions? Thank you

+2  A: 
...
group operation by new { operation.Debit, operation.Credit } into groupedOperation
...
Thomas Levesque