ActiveRecordBase has both OnSave and OnUpdate but does not have OnCreate, why and how can it be implemented? I’m using IsUnsaved in OnUpdate to determine if this is a Create or an Edit operation. Is there any better way?
ActiveRecordBase has both OnSave and OnUpdate but does not have OnCreate , why and
Share
There is no
OnCreatebecause ActiveRecord “events” are based on NHibernate’s IInterceptor, and IInterceptor doesn’t have anyOnCreate.However,
OnSaveis called for new persistent objects only, andOnUpdateonly for updates, so there is no need to checkIsUnsavedanywhere. Here’s the test that covers this.