Hello!
I'm having a procedure that uses existing classes and create new ones form those. I'm trying to do this by this code:
DestDoc := FManager.Replicate<TDocument>(SrcDoc);
DestDoc.Id := 0;
DestDoc.EntryDate := Now;
... (more changes, but removed for expamle purposes)
FManager.SaveOrUpdate(DestDoc);
FManager.Flush(DestDoc);
Is this a correct way to do it?
wlandgraf
(Wagner Landgraf)
July 17, 2023, 2:38pm
2
Make sure SrcDoc
is not in the same manager. Then you should change properties before replicating. This is the "correct" example:
SrcDoc := AnotherManager.Find<TDocument>(SomeId);
SrcDoc.Id := 0;
SrcDoc.EntryDate := Now;
DestDoc := FManager.Replicate<TDocument>(SrcDoc);
FManager.Flush(DestDoc);
Thank you, I will try.
Is possible to do it in the same manager?
wlandgraf
(Wagner Landgraf)
July 17, 2023, 7:22pm
4
Why do you want to do it in the same manager?
Because I already have one manager in the procedure
It's just easier (less code changes), if not possible, then I will create a new one.
I'm converting an application to Aurelius and I'm stuck often, but I really like Aurelis and ever problem solved is asuch a pleasure when seeing parts of the application running smoothly
wlandgraf
(Wagner Landgraf)
July 17, 2023, 8:22pm
6
Creating a new manager is a very lightweight operation and requires a few lines of code. It's really really simple.
Using the same manager is possible, but it's more complex, slower (due to needed copy operations) and requires more lines of code.
ok, thank you, I will try the solution you provided
system
(system)
Closed
July 19, 2023, 5:28am
8
This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.