I have Delphi client-server application that uses DataSnap.
On client side I have a chain of nested client datasets (cdsMaster -> cds1 -> cds2 -> cds3).
TDM = class(TDataModule)
cdsMaster: TClientDataSet;
cdsMaster_cds1: TDataSetField;
cds1: TClientDataSet;
cds1_cds2: TDataSetField;
cds2: TClientDataSet;
cds2_cds3: TDataSetField;
cds3: TClientDataSet;
end;
On server side, I have a similar set of datasets with master-detail relations.
TCoDataModule = class(TRemoteDataModule, ICoDataModule)
prvMaster: TDataSetProvider;
dsMaster: TIBDataSet;
ds1: TIBTable;
ds2: TIBTable;
ds3: TIBTable;
end;
First, I need to fetch content of cdsMaster once (without details), and then fetch full details on demand in single packet (all nested content of cds1, cds2, cds3 for selected master record). What's the best way to implement this?
If I disable option poFetchDetailsOnDemand for prvMaster, it loads the entire database on connect. If I enable it, it fetches details records one-by-one, making huge traffic overhead and performance slowdown.