Linq中的Sum 2列

Ink*_*key 5 c# linq asp.net-mvc

我想在LINQ中总结两列.以下是我的LINQ语句

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();
Run Code Online (Sandbox Code Playgroud)

我试图获得part1 + part2的总数;

当我尝试测试结果我没有得到任何价值回来我得到一个空白.

任何想法,我做错了什么?

在此输入图像描述

Yos*_*ari 0

您确定part1并且part2有价值吗?

var SigmaGood =  from n in db.tbl_dppITHr
                 where n.ProductionHour >= SelectedDateDayShiftStart
                 where n.ProductionHour <= SelectedDateEnd
                 select n.part1 ?? 0 + n.part2 ?? 0

ViewData["GoodTotal"] = SigmaGood.Sum();
Run Code Online (Sandbox Code Playgroud)