替代EntityFunctions.AddSeconds for MySQL [英] Alternative to EntityFunctions.AddSeconds for MySQL
本文介绍了替代EntityFunctions.AddSeconds for MySQL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要执行一个EF LINQ查询,使用标准的Oracle提供的点网络连接器为MySQL添加了几秒钟。不幸的是它不支持EntityFunctions.AddSeconds方法。有没有其他方法?
I need to execute an EF LINQ query that adds some seconds to a datetime against MySQL using the standard Oracle supplied dot net connector. Unfortunately it does not support the EntityFunctions.AddSeconds method. Is there an alternative approach?
var result = (from rec in db.Records where EntityFunctions.AddSeconds(rec.SomeDate, rec.SomeSeconds) select rec).FirstOrDefault();
推荐答案
DELIMITER $$
drop function IF EXISTS AddSeconds$$
create function AddSeconds(theDate datetime, seconds int)
RETURNS datetime
DETERMINISTIC
begin
return DATE_ADD(theDate, INTERVAL seconds SECOND);
end$$
这篇关于替代EntityFunctions.AddSeconds for MySQL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文