How to create lookup fields using XDataClient?

Iterate through all Invoices and add its customers to object map:



for Invoice in Invoices do
  if not Map.IsIdMapped(Invoice.Customer) then 
    Map.Add(Invoice.Customer);


Do exactly the same for the customers returned in List<TCustomer>.
Then get the final list of customers using Map.GetList, to provide it to the dataset:


adsCustomer.Close;
adsCustomer.ObjectClass := TCustomer;
adsCustomer.SetSourceList (Map.GetList);
adsCustomer.Open;