Not sure how to accomplish the date expression in the example below in the last line. A similar query fails to execute. I assume I’ll have to use some sort of Projections SqlFunction? Anyone help?
Session.QueryOver(() => myobj)
.JoinAlias(() => myobj.Object, () => o1)
.Where(() => myobj.SomeInt > o1.Date.Subtract(someTime).Minutes);
We need to convert your date operations from C# methods into DB Server functions. In case of MS SQL Server, we can use the DATEDIFF function:
DATEDIFF(datepart, startdate, endate)
Expecting that your object has a column
Dateso we can create thisICriterionHaving this SQL statement as ICriterion we can adjust your snippet:
This is just a quick example… starting point how to use NHibernate API to do it… some subquery should be more suitable to avoid using explicit
SomeIntcolumn name…