c# - Hibernate Interceptor -
the onload brings id of entity, , other properties null.
i need validate whether or not entity sampling, depending on values of properties of iaccount. here code far:
public bool onload(object entity, object id, system.collections.idictionary state) { iaccount business relationship = (iaccount)entity; account.xxxxxx homecoming true; }
how can this?
onload happens before entity object initialized, "entity" have default property values, have seen. way evaluate or alter state of entity through "state" beingness passed in.
your illustration isn't specific trying evaluate, allow pretend wish perform logging if issampling property of iaccount false:
public bool onload(object entity, object id, system.collections.idictionary state) { var issampling = state["issampling"] bool?; if( entity iaccount && issampling.hasvalue ) { if( !issampling ) log.write( string.format( "sampling business relationship id {0} not active", id ) ); } homecoming false; }
note returning false, indicate state of entity has not been altered. if want alter state of entity, must through state collection passed in (not through entity object beingness passed in), , must homecoming true.
it can hard finding documentation covers this, here 1 source (though little outdated): nhibernate.iinterceptor
c# hibernate onload interceptor
No comments:
Post a Comment