如何使用'SUM'计算我的结果中的amount1和amount2,sum2?
var sum2 = (from p in db.tbl_relacijes
select p);
Button12.Text = (sum2.Sum());
答案 0 :(得分:2)
我假设relacijes有两列amount1和amount2
Button12.Text=sum2.Sum(a=>a.amount1 + a.amount2).ToString();
答案 1 :(得分:2)
很难确定你在问什么,假设表中的amount1和amount2列?
Button12.Text = sum2.Sum(row => row.amount1 + row.amount2).ToString();
答案 2 :(得分:1)
我必须说我真的没有问题,但也许这就是你要找的东西?
var sum2 = (from p in db.tbl_relacijes
select p);
Button12.Text = (sum2.Sum(t => t.amount1 + t.amount2)).ToString();