4

如何将此语句转换为 LINQ?

SELECT Sum(Balance) FROM account WHERE name='stocks' AND userid=290;
4

3 回答 3

7
decimal sumLineTotal = (from od in account
                        where name == 'stocks' && userid == 290
                        select Balance).Sum();
于 2012-11-05T10:35:59.667 回答
5
var sum = db.account.Where(a => a.name == "stocks" && a.userid == 290)
                    .Sum(a => a.Balance);
于 2012-11-05T10:36:26.280 回答
0

像这样:

myBalanceSum = account.Where(x => x.name == 'stocks' && x.userid == 290 ).Sum(x => x.Balance);
于 2012-11-05T10:43:24.473 回答