且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

实体框架 - MySQL - 日期时间格式问题

更新时间:2023-02-20 11:35:09

@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.