EntityFunctions support in MySql

前端 未结 2 1842
滥情空心
滥情空心 2021-01-25 23:17

I am getting error while using EntityFunctions.DiffMinutes() with MySQL. Below is my code

return db.DiscoveredDevices.Where(m => EntityFunctions.DiffMinutes((DateTime)m.

相关标签:
2条回答
  • 2021-01-25 23:52

    The DiffMinutes function doesn't exist in MySQL, just create it and will work:

    CREATE FUNCTION `DiffMinutes`(timeValue1 datetime, timevalue2 datetime) RETURNS int(11)
        DETERMINISTIC
    BEGIN
    RETURN TIMESTAMPDIFF(MINUTE, timeValue1, timevalue2);
    END
    
    0 讨论(0)
  • 2021-01-26 00:14

    I think maybe MySQL doesn't implement that Function...

    you can use the other way like this:

        DateTime begin = DateTime.Now - pollTime;
        DateTime end = DateTime.Now + pollTime;
    
        var result = (from s in db.DiscoveredDevices where s.LastPollTime > begin && s.LastPollTime < end && && s.Status == true select s).ToList();
        return result;
    
    0 讨论(0)
提交回复
热议问题