someDS.someDT.Where(x => x.Amount is not DBNull)
.Sum(x => x.Amount);
根据链接How to compare DBNull value,上述代码应该没问题,还是有其他办法来处理上述情况?
答案 0 :(得分:0)
如果您的Amount
是可空的decimal
,那么您可以将null
可空decimal
类型的值视为
someDS.someDT.Where(x => x.Amount.HasValue == true)
.Sum(x => x.Amount);
答案 1 :(得分:0)
someDS.someDT.Where(x => x.Amount != DBNull.Value)
.Sum(x => x.Amount);