I need to clone an entity and all its dependencies. That is some case could have several TList<>
I have found this generic solution for cloning:
Looking onto this, remembered that you have the serializer and deserializer in Aurelius already,
There are two undocumented methods in TMappingExplorer that you can use to help you with this: CopyFieldValues and SetIdValue. You can yse CopyFieldValues to clone the object, and then SetIdValue (passing NULL for example) to clear the id value. Note that since those are undocumented methods, they are subject to change in future versions.
For example, if I have an invoice that I need to clone:
In this case you have to do something manually indeed. It depends on your business logic.
Wagner,
It looks like it will work.
Wagner
If you add an item to a collection, Aurelius will set that item belonging to that collection on a Flush.
Is possible to use Evict on the "old" document and then combine the items in the the same way? Then set all the IDs to 0 (zero) and re-save the same (now evicted and with all IDs to zero) document again with the manager?
Would this work?
I'm stuck on the same problem - clone a document with items.. If there is some example code, I would be great.
This is a 9-year old thread. I don't know exactly what are you struggling with, what do you want to achieve, exactly?
With modern Aurelius you an easily use Merge/Replicate to "clone" an entity into an object manager.
I will close this topic and if you have a specific question please describe it from scratch in another topic, thank you.
This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.