The Problem: All tables in our database have CreatedDate, CreatedBy, ChangedDate, ChangedBy fields which I want to be set automatically when Saving / Updating an ActiveRecord entity.
My first try was to override the Save() and Update() methods. But these methods only get called when I do a direct Save() or Update() on the entity. They are not being called in a Master - Detail scenario where I call Save() only on the master.
Next try were the OnSave() and OnUpdate() methods, but here changes in the fields were not persisted in the database.
Finally I tried the BeforeSave() method. But this method is not called when updating.
The Question: How can set these CreatedDate, CreatedBy, ChangedDate, ChangedBy fields automatically during a Save() or Update()?