0

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 doesn't work since I cannot group on two columns.

Any suggestions?

ekad
  • 14,436
  • 26
  • 44
  • 46
bzamfir
  • 4,698
  • 10
  • 54
  • 89

1 Answers1

2
...
group operation by new { operation.Debit, operation.Credit } into groupedOperation
...
Thomas Levesque
  • 286,951
  • 70
  • 623
  • 758