Use Now function in ORM queries
Is it possible to generate SQL queries by ORM that use NOW function from database? For example:
select * from Order where OrderDate > Now() - Interval 1 Day
insert into Orders Set OrderDate = Now()
I am primarily interested in N开发者_如何学CHibernate and Entity Framework
You can not use example queries for dialect-specific functions because the properties will not match the desired types (if OrderDate
is a DateTime
there is no way to specify Now() - Interval 1 Day
as a DateTime
).
If you have the dialect-specific functions defined (I believe you can use the techniques described at http://weblogs.asp.net/ricardoperes/archive/2011/06/14/adding-custom-sql-functions-to-nhibernate-at-runtime.aspx) you may be able to use Criteria queries.
精彩评论