Skip to content Skip to sidebar Skip to footer

Entityfunctions Support In Mysql

I am getting error while using EntityFunctions.DiffMinutes() with MySQL. Below is my code return db.DiscoveredDevices.Where(m => EntityFunctions.DiffMinutes((DateTime)m.LastPoll

Solution 1:

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 ==trueselect s).ToList();
    returnresult;

Solution 2:

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

CREATEFUNCTION `DiffMinutes`(timeValue1 datetime, timevalue2 datetime) RETURNSint(11)
    DETERMINISTICBEGINRETURN TIMESTAMPDIFF(MINUTE, timeValue1, timevalue2);
END

Post a Comment for "Entityfunctions Support In Mysql"