有没有办法(不使用 try catch)在下面的 ps.sum 中检查零,这样它就不会引发除以零错误?
var procVsTotPkg = unitGroup.Join(procSums, g => new
{
g.DeptID,
g.UnitLoc,
g.Proc
},
ps => new
{
DeptID = ps.key.deptID,
UnitLoc = ps.key.unitLoc,
Proc = ps.key.procName
}, (g, ps) => new procVSUnitTotalJoin
{
dept = g.DeptID,
uloc = g.UnitLoc,
procName = g.Proc,
unitName = g.Unit,
unitTotal = g.CurrVal,
procTotal = ps.sum,
PTPcntOfUT = Math.Round((g.CurrVal / ps.sum) * 100, 2)
}).Single();