Hi,
I have created a helper that is setup to close the session at HttpContext.EndRequest but in some of the other documentation I have seen, the session gets closed right after the save/update/delete has occured.
For example, a delete method on my helper looks like this:
Code:
public static void DeleteWithCommit(object objectToDelete, System.Data.IsolationLevel isolationLevel)
{
ITransaction transaction = null;
try
{
transaction = Session.BeginTransaction(isolationLevel);
Session.Delete(objectToDelete);
transaction.Commit();
}
catch
{
if (transaction != null)
{
transaction.Rollback();
}
throw;
}
}
I don't have a finally block to close the session because this is hooked up to happen at HttpContext.EndRequest. Is this OK or should I really be closing the session in a finally block? If I do close it in a finally block, does this mean that I will not be able to access properties on a saved or updated object without re-querying?
Thanks,
Jason