Canonical Function “EntityFunctions.TruncateTime” does not exist in MYSQL

前端 未结 2 696
遥遥无期
遥遥无期 2020-12-06 03:27

I\'m trying to run this query:

DateTime DDate=DateTime.Today; //Today\'s date without Time
var v= db.measurements.Where(m => EntityFunctions.TruncateTime(         


        
2条回答
  •  悲&欢浪女
    2020-12-06 03:59

    I couldn't resolve it, so I just created a Function named "TruncateTime" in the database.

    Create FUNCTION TruncateTime(dateValue DateTime) RETURNS date
    return Date(dateValue);
    

    And it works, but I don't like it.

    These people did similar things:

    Alternative to EntityFunctions.AddSeconds for MySQL

    CurrentUtcDateTime does not exist - Entity Framework and MySql

    So now I think that might be unnecessary and I can just call it directly from the database and still get entities, something like this:

    var x = db.ExecuteStoreQuery(@"SELECT field1,field2
    FROM   Measurements
    WHERE  Date(InDate) = {0}", DDate);
    

    And that's all.

提交回复
热议问题