I am using an IInterceptor to overrule the onload method. The method itself returns a boolean that (for as far as i understand) should overrule the load (setting the properties) of the entity when you return "true" in the interceptor.
To do so I changed the following code in Impl\SessionImpl.cs:
Code:
public void InitializeEntity( object obj )
{
..
interceptor.OnLoad( obj, id, hydratedState, persister.PropertyNames, types );
persister.SetPropertyValues( obj, hydratedState );
..
into:
Code:
public void InitializeEntity( object obj )
{
..
if(!interceptor.OnLoad( obj, id, hydratedState, persister.PropertyNames, types ))
persister.SetPropertyValues( obj, hydratedState );
..
My Interceptor looks like:
Code:
public bool OnLoad(object entity, object id, object[] state, string[] propertyNames, NHibernate.Type.IType[] types)
{
if(entity is SomeClass)
{
((SomeClass)entity).NHPreLoad();
for(Int32 i=0; i<state.Length; i++)
{
entity.GetType().GetProperty(propertyNames[i]).SetValue(entity, state[i], null);
}
((SomeClass)entity).NHPostLoad();
return true;
}
else
return false;
}
Is this correct?