I have an entity TPerson and a lazy association to TPersonMemos. (Master/Detail) One Person has many memos. The loadingprocess is too slow to load the memo data immediately.
I use Omnithread Library. How can I load the memos?
Here are my code for loading the Person:
function TdmPerson.LoadPerson(APersonID: TGuid; AJobNum: Integer; ACallback: TModelCallbackEvent): Boolean;
begin
Async(
procedure begin
FPerson := XClient.Get<TPerson, TGuid>(APersonID);
end)
.Await(
procedure begin
if assigned(ACallback) then
if FPerson <> nil then
ACallback( self, AJobNum, GUIDToString( FPerson.PersonID))
else
ACallback( self, AJobNum, '');
end);
end;
And what can I do for Memos
function TdmPerson.LoadPersonMemo( APersonID: TGuid; AJobNum: Integer; ACallback: TModelCallbackEvent): Boolean;
begin
Async(
procedure begin
FPerson.PersonMemoList. := XClient. ... ???
end)
.Await(
procedure begin
if assigned(ACallback) then
// Do something
end);
end;
The proxy uses the same XClient object to load the proxied list. You must be sure XClient object is still "alive" (not destroyed) by the time FPerson.PersonMemoList is called.