There were situations when I had to make sure that I Get (or Load) fresh entity object from database. But with NHibernate, until I change configuration forever, there is no other way to do so except to use UnitOfWork.Refresh method.
This is expensive when I the object is not in cache at frist place. It makes 2 database hit.
What I need is something like this,
UnitOfWork.GetFresh
(object pk)
OR
if(UnitOfWork.IsCached(object pk) && !UnitOfWork.IsDirty(object pk)
{
//Refresh
}
else
{
//Get
}
No comments:
Post a Comment