Show/Hide Toolbars

TMS XData Documentation

Navigation: TXDataClient

Requesting an Entity List

Scroll Prev Top Next More

Use the List method to query and retrieve a list of entities from the server:

 

var
  Fishes: TList<TFish>;
begin
  Fishes := Client.List<TFish>;

 

The TXDataClient.List<T> function will always create and retrieve an object of type TList<T>. By default you must manually destroy that list object later, as explained in memory management topic.

Optionally you can provide a query string to send to the server to perform filtering, order, etc., using the XData query options syntax:

 

Customers := Client.List<TCustomer>('$filter=(Name eq ''Paul'') or (Birthday lt 1940-08-01)&$orderby=Name desc');

 

Use the non-generic version in case you only know the type of the entity class at runtime. In this case, the function will create and return an object of type TList<TObject>:

 

var
  Fishes: TList<TObject>;
begin
  Fishes := XClient.List(TFish);

 

You also can use Count method to retrieve only the total number of entities without needing to retrieve the full entity list:

 

var
  TotalFishes: Integer;
  TotalCustomers: Integer;
begin  
  TotalFishes := Client.Count(TFish);
  TotalCustomers := Client.Count(TCustomer, '$filter=(Name eq ''Paul'') or (Birthday lt 1940-08-01)&$orderby=Name desc');
end;