public override bool OnFlushDirty(object entity, object id, object[] currentState, object[] previousState, string[] propertyNames, IType[] types) { var persistenceAware = entity as IPersistenceAware; persistenceAware?.OnUpdate(); if (previousState == null) { _msg.DebugFormat("Dirty flushing with unknown previous state ({0})", entity); string stack = GetStack(); _msg.DebugFormat( "IInterceptor.OnFlushDirty() found detached entity (type: {0}){1}{1}{2}", entity?.GetType().Name ?? "<entity is null>", Environment.NewLine, stack); } else { var metadata = entity as IEntityMetadata; if (metadata != null) { EntityMetadataUtils.DocumentUpdate(metadata, currentState, previousState, propertyNames); } } // NOTE: collections are also reported, but the referenced entities have the *new* state // in both currentState and previousState return(base.OnFlushDirty(entity, id, currentState, previousState, propertyNames, types)); }
public override bool OnSave(object entity, object id, object[] state, string[] propertyNames, IType[] types) { var persistenceAware = entity as IPersistenceAware; persistenceAware?.OnCreate(); var metadata = entity as IEntityMetadata; if (metadata != null) { EntityMetadataUtils.DocumentCreation(metadata, state, propertyNames); } return(base.OnSave(entity, id, state, propertyNames, types)); }