Event AfterLoad for Proxy

For normal we are using Proxy-Fields for Associations and ManyValuedAssociations.

Because, there are a lot of possible situations, trigger Proxy.Load, I would need an Event AfterLoad, like ProxyController have, so that I could do some stuff after my proxy is loaded.

It would be fine for me, if I could just assign my Event in constructor of my Entity.

For example:

[Entity]
TEntity2 = class;

[Entity]
TEntity = class
private
  FProxy: Proxy<TEntity2>;
  FProxyList: Proxy<TList<TEntity2>>;
  
  procedure AfterLoadProxy(aSender: TObject); // should be triggering Proxy-Field
public
  constructor Create;
end;
...

constructor TEntity.Create;
begin
  inherited;
  FProxy.OnAfterLoad := AfterLoadProxy;
  FProxyList.OnAfterLoad := AfterLoadProxy;
end;

Just out of curiosity, what kind of code you want to add in such event handler?

For example registering this fetched Entities to an owner, handling memory-management in cases TObjectManager does not, (but does while Proxy is loaded).

1 Like

another example is, that this would allow us to use TList-OnNotify Event for monitoring changes.
Right now it works until proxy is loaded...

1 Like