Object and Controller

Hi,

I'm still experimenting Aurelius.

Is there a way to make something like this ?

class function TResidenceController.Get(AId: Variant): TResidence;
var
  AController: TResidenceController;
begin
  AController := TResidenceController.Create;
  try
    Result := AController.FManager.Find<TResidence>(AId);
  finally
    AController.Free
  end;
end;

Actually when I free my controller, my object no longer contains my loaded value.

If by destroying the controller you are destroying the manager, the objects it contains will also be destroyed. To keep the objects alive you should use:


AController.FManager.OwnsObjects := false;

this way they will not be destroyed.
Or you can use

AController.FManager.Evict(Result);

to remove the Residence object from the manager. Note that you will need to take care of destroying the object later, including the associated objects.

Thanks Wagner.


Evict is what I need :)
 
 I still experiment Aurelius for a future project.