How do I SUM a column in a table with entity (asp.net c#)

bmanmike39
bmanmike39 used Ask the Experts™
on
I am trying to SUM the Amount(getPO.Amount) column in my returned list.


var getPO = pr.Invs.Where(z => z.invNumber == invNumber).ToList();

var getSum =  "do somthing getPO.sum();"

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Retired
Distinguished Expert 2017
Commented:
Hi  bmanmike39;

Try this, it should give what you need.
var getPO = pr.Invs.Where(z => z.invNumber == invNumber).ToList();

var getSum =  getPO.Sum( po => po.Amount);

Open in new window

Author

Commented:
Thanks! That was what I was looking for.
Fernando SotoRetired
Distinguished Expert 2017

Commented:
Not a problem bmanmike39, glad I was able to help.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial