views:

13

answers:

0

Hello,

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 basically 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?

Thank you