Nullable object must have a value?

后端 未结 8 2370
旧时难觅i
旧时难觅i 2020-12-09 14:54

On the line: bool travel = fill.travel.Value; I am getting the following error:

Nullable object must have a value

a

8条回答
  •  伪装坚强ぢ
    2020-12-09 14:58

    The value coming from the database is a nullable boolean. When you call Nullable.Value, and the value is null, you will get this exception. Consider checking the property Nullable.HasValue before calling .Value.

提交回复
热议问题