Ah, I ran into some similar issues when trying to automatically set some columns when entities are saved (UpdateBy, UpdateTime, etc).
I've been playing around with ways to do this automatically, and the way I'm thinking now is to dynamically check for the fields named "UpdateBy", "UpdateTime" and set the IEntityField2 values in my own DataAccessAdapter during save/updates/etc.
The place I initially though of doing it was in SaveEntity. However, of the four SaveEntity overloads, only two are virtual (marked with *).
bool SaveEntity(IEntity2)
bool SaveEntity(IEntity2, bool)
* bool SaveEntity(IEntity2, bool, IPredicateExpression)
* bool SaveEntity(IEntity2, bool, IPredicateExpression, bool)
So I tried overriding the fourth one, thinking that all the rest of them eventually called that one with default params, but it looks like I have to override both of the virtual ones for some reason (which I did, and it catches all four overloads with my code now).
What is the recommend way of hooking into the save process? This could also apply to SaveEntityCollection and many other methods, too.
Maybe a OnBeforeSaveEntity() virtual method would be nice, which would happen before the IActionQuery was built?
Or maybe I'm going about this all wrong?