I am trying to sum two columns that i have in LINQ. The following is my LINQ statement
var SigmaGood = from n in db.tbl_dppITHr
where n.ProductionHour >= SelectedDateDayShiftStart
where n.ProductionHour <= SelectedDateEnd
select n.part1 + n.part2
ViewData["GoodTotal"] = SigmaGood.Sum();
I am trying to get a total for part1 + part2;
When i try and test the result i dont get any value back i get a blank.
Anyone any ideas what i am doing incorrect?
I would say blank must mean the key you're storing the value against doesn't match the key you are reading/displaying. If it did you would at least see 0
, not blank.
Do it in two steps and debug it.
var total = sigmaGood.Sum();
ViewData["GoodTotal"] = total; //breakpoint on this line and check value of total.
Or hardcode a test value, I bet it still comes out blank:
ViewData["GoodTotal"] = 1234;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With