Show/Hide Toolbars

TMS XData Documentation

Navigation: TXDataClient

Requesting a Single Entity

Scroll Prev Top Next More

To request a single entity, use the Get generic method passing the Id of the object as parameter:


Customer := Client.Get<TCustomer>(10);
State := Client.Get<TState>('FL');


The Id parameter is of type TValue, which has implicit conversions from some types like integer and string in the examples above. If there is no implicit conversion from the type of the id, you can use an overloaded method where you pass the type of Id parameter:


  InvoiceId: TGuid;
  { ... get invoice Id }
  Invoice := Client.Get<TInvoice, TGuid>(InvoiceId);


You can use the non-generic version of Get in case you only know the entity type at runtime (it returns a TObject and you need to typecast it to the desired type):


Customer := TCustomer(Client.Get(TCustomer, 10)));