I've looked around and can't find too much. But is it possible to do something like this using HQL in nHibernate:
Session.CreateQuery(@"DELETE FROM MyObject mo WHERE (mo.AlteredDate + mo.ExpiryDetails.ExpiryTimestamp) < :pNow") .SetDateTime("pNow", DateTime.Now);
So basic开发者_开发问答ally I want to delete all MyObjects from the database where the last time the object was altered (mo.AlteredDate - a DateTime) plus an amount of time such as 2 days and 5 hours (ExpiryDetails.ExpiryTimestamp) is less than now.
Or is it best to retrieve the objects and do the caculation in code using the .NET framework?
Super late to answer, but I did something like this & it works:
IQuery query = Session.CreateQuery("select x from OBJECT x where x.DateTimeForCompare > :dateTimeForCompare2");
query.SetDateTime("dateTimeForCompare2", DateTime.Today);
IList<OBJECT> xx = query.List<OBJECT>();
精彩评论