db null进入属性asp.net

时间:2017-05-31 02:33:07

标签: c# asp.net null dbnull

我在代码中遇到错误收到错误 表'wsm_View_PurchaseOrderList'中'TotalValue'列的值为DBNull。

Initialize From State

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; }
}

1 个答案:

答案 0 :(得分:1)

尝试检查DBNull,如下所示:

let sums = (0...100).flatMap { $0 % 2 != 0 ? Double($0) + 5.0 : nil  }