Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I use Sum() in Linq?

Tags:

c#

mysql

linq

How do I convert this statement into LINQ?

SELECT Sum(Balance) FROM account WHERE name='stocks' AND userid=290;
like image 628
user1719311 Avatar asked Dec 15 '22 17:12

user1719311


1 Answers

decimal sumLineTotal = (from od in account
                        where name == 'stocks' && userid == 290
                        select Balance).Sum();
like image 122
John Woo Avatar answered Dec 18 '22 08:12

John Woo