Can I re-use the same entity to do the save multiple times, like below?
var MyEntity := TMyEntity.Create;
for I := 0 to 1000 do begin
MyEntity.Name := RandomName();
ObjectManager.Save(MyEntity);
end
Can I re-use the same entity to do the save multiple times, like below?
var MyEntity := TMyEntity.Create;
for I := 0 to 1000 do begin
MyEntity.Name := RandomName();
ObjectManager.Save(MyEntity);
end
No, because the manager needs to track the instance of each entity. If you do that, the same instance will be associated with multiple entities (with different ids).
You must either create a new instance before each Save
, or use Replicate
method which will automatically create a new instance and copy the properties from the original instance to the new one.
This topic was automatically closed 60 minutes after the last reply. New replies are no longer allowed.