I've a class that looks like this:
Code:
public class Something : ILifeCycle
{
int idToExtenralResource;
ExtenralResource res;
public ExtenralResource Resource
{
get { return res; }
set { res = value; idToExtenralResource = res.Id; }
}
void ILifeCycle.OnLoad(ISession s, object id)
{
res = GetExternalResource(idToExternalResource);
}
}
The idToExtenralResource is stored in the table and I need to load that, but it shouldn't be exposed.
It's mapped likethis:
Code:
<property name="idToExtenralResource" access="field" column="res_id"/>
I understand that you shouldn't use the life cycle to load dependant objects via NHib, does the same advice apply to external resources that I'm getting via other means?
Second, I understand that OnUpdate() is not guranteed to be called, which is why I'm using the update on method set.