The specified member of type 'DateTime' is not supported in LINQ to Entities

I am using the latest version of the connector, 6.3.3 beta, to connect to the mysql database through Entity Framework 4 in VS2010.

I have the following Linq statement that uses the TIMESTAMP query - createdDate - in the query. Here is the code:

        int timeThreshold = 5;
        DateTimeOffset cutoffTime = DateTime.Now.AddMinutes(-timeThreshold);

        using (var context = new opusismEntities())
        {
            var unprocessedMessages = from m in context.messages
                                      where m.createdDate <= cutoffTime
                                      select m;
            try
            {
                foreach (var message in unprocessedMessages)
                {
                    int gfff = 5;
                }
            }
            catch (Exception e)
            {
                string exceptionString = e.InnerException.ToString();
            }

        }

The CLR throws the following exception:

"MySql.Data.MySqlClient.MySqlException(0x80004005): , . --- > MySql.Data.MySqlClient.MySqlException(0x80004005): /.\r\n at MySql.Data.Types.MySqlDateTime.MySql.Data.Types.IMySqlValue.WriteValue( MySqlPacket, Boolean, Object, Int32)\r\n MySql.Data.MySqlClient.MySqlParameter.Serialize( MySqlPacket, , MySqlConnectionStringBuilder)\r\n MySql.Data.MySqlClient.Statement.SerializeParameter( MySqlParameterCollection, MySqlPacket, parmName)\r\n MySql.Data.MySqlClient.Statement.InternalBindParameters(String sql, MySqlParameterCollection parameters, MySqlPacket )\r\n MySql.Data.MySqlClient.Statement.BindParameters()\r\n MySql.Data.MySqlClient.Statement.Execute()\r\n MySql.Data.MySqlClient.PreparableStatement.Execute()\r\n MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavio r)\r\n MySql.Data.MySqlClient.MySqlCommand.ExecuteReader( CommandBehavior)\r\n MySql.Data.Entity.EFMySqlCommand.ExecuteDbDataReader( CommandBehavior)\r\n System.Data.Common.DbCommand.ExecuteReader( CommandBehavior)\r\n System.Data.EntityClient.EntityCommandDefinition.ExecuteStoreCommands(EntityCommand entityCommand, CommandBehavior)"

Ive : http://bugs.mysql.com/bug.php?id=52550

DateTime DateTimeOffset:

DateTime cutoffTime = DateTime.Now.AddMinutes(-timeThreshold);

...
var unprocessedMessages = from m in context.messages
                                      where m.createdDate.DateTime <= cutoffTime
                                      select m;

.createdDate.DateTime, Entity Framework :

'DateTime' LINQ to Entities


NET/Connector.

, GA.3 6.3.4 , - - 6.3.3.

+3
1

, LINQ to Entities.. /, ... DateTime, .

DateTime dt=createdDate.DateTime;

DateTime... ..., . , , ...

+1

Source: https://habr.com/ru/post/1760346/


All Articles