select multiple columns using linq and sum them up

Posted by Yustme on Stack Overflow See other posts from Stack Overflow or by Yustme
Published on 2010-05-20T20:43:53Z Indexed on 2010/05/20 21:00 UTC
Read the original article Hit count: 460

Filed under:
|
|
|
|

Hi,

How can i select multiple columns and calculate the total amount.

For example, in my database i got a few fields which are named:

5hunderedBills, 2hunderedBills, 1hunderedBills, etc.

And the value of those fields are for example:

5, 2, 3

And the sum would be:

5hunderedBills * 5 + 2hunderedBills * 2 + 1hunderedBills * 3

How can i do that with LINQ in one select statement?

© Stack Overflow or respective owner

Related posts about c#

Related posts about LINQ