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?
There is no OnCreate
because ActiveRecord "events" are based on NHibernate's IInterceptor, and IInterceptor doesn't have any OnCreate
.
However, OnSave
is called for new persistent objects only, and OnUpdate
only for updates, so there is no need to check IsUnsaved
anywhere. Here's the test that covers this.