How开发者_如何学运维 to use 'SUM' to calculate amount1 and amount2 that is in my result, sum2?
var sum2 = (from p in db.tbl_relacijes
select p);
Button12.Text = (sum2.Sum());
I am assuming that relacijes has two columns for amount1 and amount2
Button12.Text=sum2.Sum(a=>a.amount1 + a.amount2).ToString();
Difficult to be sure what you're asking, assuming amount1 and amount2 columns in the table?
Button12.Text = sum2.Sum(row => row.amount1 + row.amount2).ToString();
I must say I don't really get the question, but maybe this is what you're looking for?
var sum2 = (from p in db.tbl_relacijes
select p);
Button12.Text = (sum2.Sum(t => t.amount1 + t.amount2)).ToString();
精彩评论