Object cannot be cast from DBNull to other types. 返回

SqlSugar 老数据
3 2273

最近调用Insertable(entity).ExecuteCommand()<=0;提示Object cannot be cast from DBNull to other types.不知道什么原因,着急死了。。。

热忱回答(3)

  • 后面不断测试发现 ,应该是数据字段为可空的时间类型,实体属性类型:DateTime?,这种数据类型,该属性为null,保存值,使用Insertable(entity).ExecuteCommand()插入到数据,就提示Object cannot be cast from DBNull to other types.这个错误,望指导下,怎么解决,比较着急。。。

    0 回复
  • 试下给属性加个默认值

    0 回复
  • 更新一下版本就好了,

    0 回复