我在代码中遇到错误收到错误 表'wsm_View_PurchaseOrderList'中'TotalValue'列的值为DBNull。
public decimal TotalValue {
get {
try {
if (object.ReferenceEquals(tablewsm_View_PurchaseOrderList.TotalValueColumn, DBNull.Value)) {
return 0.0;
} else {
return Convert.ToDecimal(this(this.tablewsm_View_PurchaseOrderList.TotalValueColumn));
}
} catch (System.InvalidCastException e) {
throw new global::System.Data.StrongTypingException("The value for column 'TotalValue' in table 'wsm_View_PurchaseOrderList' is DBNull" + ".", e);
}
}
set { this(this.tablewsm_View_PurchaseOrderList.TotalValueColumn) = value; }
}
答案 0 :(得分:1)
尝试检查DBNull,如下所示:
let sums = (0...100).flatMap { $0 % 2 != 0 ? Double($0) + 5.0 : nil }