LinQ to objects GroupBy() by object and Sum() by amount
- by Daniil Harik
Hello,
I have pretty simple case which I started solving using foreach(), but then I thought I could do It using Linq
Basically I have IList that contains PaymentTransaction objects and there are 2 properties Dealer and Amount
I want to GroupBy() by Dealer and Sum() bv amount.
I tried to accomplish this using following code, but unfortunately it does not work
var test = paymentTransactionDao.GetAll().GroupBy(x => x.Dealer).Sum(x => x.Amount);
Want exactly I'm doing wrong here?
I'm sorry if this question is too simple.
Thank You