开发者

How to use 'SUM' to calculate amount1 and amount2?

开发者 https://www.devze.com 2023-01-27 05:09 出处:网络
How开发者_如何学运维 to use \'SUM\' to calculate amount1 and amount2 that is in my result, sum2?

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();
0

精彩评论

暂无评论...
验证码 换一张
取 消