Given a structure like TOrder->TPosition - what would be the best way to implement a "new with this data" feature?
I used to work with client datasets and had a generic way to do create a new master record along with child records and seek a way to do the same with Aurelius.
Maybe it is easiest at the TAureliusDataset-level?
tx for every idea!
Hi Bernd, sorry but I didn't understand your question. Are you talking about saving the whole structure at once? If that's the case, then you just need to create TOrder instance, a bunch of TPosition instances, add them to a TOrder.Positions property that is a TList<TPosition> and then save TOrder, the parent and all children will be saved at once.
One option is to clear the ID of the object and Merge it into another manager:
Obj := Manager.Find<TMyClass>(1);
Manager2 := TObjectManager.Create(Conn);
Obj.Id := 0;
Manager2.Merge<TMyClass>(Obj);
Ok, thanks for this.
TInvoice = class
private
FCustomer: TCustomer;
FInvoiceItems: TList<TInvoiceItem>;
What happens to the FInvoiceItems then?
In most operations that TObjectManager performs, the operations are cascaded to associated objects if such operation is flagged to be cascaded (See CascadeType: http://www.tmssoftware.biz/business/aurelius/doc/web/association.html)
You just want to clone the object. In this case it's out of Aurelius scope and you could simply clone it manually or using RTTI. Aurelius has an internal method to do that which can be called using
TMappingExplorer.Default.CopyFieldValues(Source, Target);