NHibernate 无法将 MySQL 日期/时间值转换为 System.DateTime [英] NHibernate Unable to convert MySQL date/time value to System.DateTime

查看:21
本文介绍了NHibernate 无法将 MySQL 日期/时间值转换为 System.DateTime的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到无法将 MySQL 日期/时间值转换为 System.DateTime"错误,因为据我所知,我有 0000-00-00 00:00:00 的记录.现在,虽然数据永远不应该是这样(它应该为空),但在某些情况下可能会发生这种情况,我不希望我的整个应用程序因此而崩溃.我正在使用 NHibernate,我尝试添加更改我的连接字符串以允许零日期时间,因此连接字符串配置如下所示:

I am getting the "Unable to convert MySQL date/time value to System.DateTime" error because from what I can tell I have a record with 0000-00-00 00:00:00. Now while the data should never be that (it should be null) there are cases when this might happen and I don't want my entire application to crash because of it. I am using NHibernate and I tried adding change my connection string to allow zero datetime so the connection string configuration looks like:

<property name="connection.connection_string">
 Server=localhost;Database=user_system;User ID=root;Password=root;
   Allow Zero Datetime=true;
</property>

但是我仍然收到该错误.如何让 NHibernate 允许时间戳/日期时间/数据/时间为零值?

However I still receive that error. How can I allow NHibernate to allow zero values for timestamp/datetime/data/time?

推荐答案

添加Convert Zero Datetime=true;,可能会有帮助!

这篇关于NHibernate 无法将 MySQL 日期/时间值转换为 System.DateTime的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆