如何在Linq to SQL表达式中使用SQL的GETDATE()和DATEADD()? [英] How do I use SQL's GETDATE() and DATEADD() in a Linq to SQL expression?
本文介绍了如何在Linq to SQL表达式中使用SQL的GETDATE()和DATEADD()?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果我有这样的Linq
到SQL
表达式:
If I have a Linq
to SQL
expression like this:
from subscription in dbContext.Subscriptions
where subscription.Expires > DateTime.Now
select subscription
我希望它使用SQL Servers GETDATE()
函数,而不是计算机运行C#
程序的时间.
I want this to to use the SQL Servers GETDATE()
function instead of the time of the machine running the C#
program.
下一个问题是如何翻译:
The next question would be how to translate this:
DateTime.Now.AddDays(2)
对此:
DATEADD(dd, 2, GETDATE())
推荐答案
查看全文