I was looking on Aurelius code and could not find what I am going to ask.
I was looking for a way to catch events of Save/Update of the manager.
I can eventually create my own Save, but I was thinking in using the ObjectManager because the TAureliusDataSets also Save;/Update using it.
My intention is catch something like BeforeSave/AfterSave or something similar, in a way that I could ask my entity to be prepared to be saved and check consistency. And also I have to generate a LOG of operations, that could be the correct moment for that.
The problem keeps bugging me is that TAureliusDataset is somehow autonomous of the rest of the structure (in my use case at least) and it does things that the rest of my structure is not aware, since dataset is only a visual way to use livebinding for me.
I need a centralized way, that is not control based (ie, not dropping a control in the form) where I could handle this kind of events when persisting the entities. I believe this could be at TObjectManager level (I have one of this for each model, similar the Music example)
Well, certainly you are very aware of the need, but just stressing it a little to make that request more complete ( i did not see a way to add to that request description):
centralized events on the TObjectManager (or related) for ANY data operation with the manager, including the TAureliusDataSet events (probably when using TAureliusDataSet it will have 2 places generating events, not sure about that, it can be useful eventually)
Same events on TObjectManager that there is on TAureliusDataSet, or at least the ones that are not DataSet-only related
One that is specially important is when a New Entity is needed to be created, there is a need to have a centralized way to create and initialize the Entity. Even if the Aurelius load the data from the database the Entity can have more information, specially about context that needs to be initialized . My classes are getting complex.
Possibility to "cancel/abort" the operation when saving/updating. This is needed when the save/update is requested and I have to ask the Entity if it is ok to be saved. Eventually the object have something missing and it is not able to continue, then the save/update needs to stopped in a way that can be recovered. (to ask user input etc then goes back to saving again)
thank you, right now I will be following the repository class way.
Yes, for now, Aurelius creates automatically all objects loaded from database. We plan to add an object factory feature. Actually it already uses an object factory, but for now that factory is a singleton and cannot be changed.