We intercept NHibernate activity for the following reasons:
- logging
- authorization validation
- generic validation
- trigger events
public bool OnFlushDirty(object entity, object id, object[] currentState, object[] previousState, string[] propertyNames, NHibernate.Type.IType[] types)
{
Model.EntityObject entityObject = entity as EntityObject;
if (entityObject == null)
{
return false;
}
return entityObject.OnFlushDirty(entity, id, currentState, previousState, propertyNames, types);
}
The way we hooked generic logging is quiet simple: we've intercepted OnFlushDirty and are just logging object[] currentState.
The entity update upon trigger is not immediate. Other than just setting properties on parameter entity, we have to set currentstate:
currentState[(int)propertyNames["MyProperty"]] = ...;
There goes the strongly typed advantage...
No comments:
Post a Comment