实体框架 - MySQL - 日期时间格式问题 [英] Entity Framework - MySQL - Datetime format issue

查看:200
本文介绍了实体框架 - MySQL - 日期时间格式问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



每当我运行以下查询:

  var docs =(from d in base.EntityDataContext.document_reviews 
select d).ToList();

我收到以下异常:

 无法将MySQL日期/时间值转换为System.DateTime。 
MySql.Data.Types.MySqlConversionException:无法将MySQL日期/时间值转换为System.DateTime

文档审查表有两个日期/时间字段。其中一个是无效的。



我已尝试在连接字符串中放置以下内容:

  Allow Zero Datetime = true; 

但我还是收到例外。



任何有解决方案的人

解决方案

@effkay - 如果你解决了这个问题,那么如果你可以发布答案,这将是很棒的。 / p>

另外,如果其他人也有一个很好的解决方案:)。



编辑: / strong>



该解决方案可以在 http://dev.mysql.com/doc/refman/5.1/en/connector-net-connection-options.html 连接器文档。



我需要将转换零日期时间设置为true,现在可以使用。



hth。 p>

I have a simple table with few date fields.

Whenever I run following query:

var docs = ( from d in base.EntityDataContext.document_reviews
select d ).ToList();

I get following exception:

Unable to convert MySQL date/time value to System.DateTime. 
MySql.Data.Types.MySqlConversionException: Unable to convert MySQL date/time value to System.DateTime

The document reviews table has two date/time fields. One of them is nullable.

I have tried placing following in connection string:

Allow Zero Datetime=true;

But I am still getting exception.

Anyone with a solution?

解决方案

@effkay - if you solved this it would be great if you could post the answer.

Also if anyone else has a solution that would be great too :).

Edit:

The solution can be found in the http://dev.mysql.com/doc/refman/5.1/en/connector-net-connection-options.html connector documentation.

I needed to set "Convert Zero Datetime" to true, and now it works.

hth.

这篇关于实体框架 - MySQL - 日期时间格式问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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