XDataWebDataset and service operations


I'm trying to display my XData service in a XDataWebDataset (in a win64 app). I have a problem that I don't know how to use the server response in the dataset.

Server method is this:

function TEasyService.QueryProducts(Query: TXDataQuery): TList<TProduct>;
  Result := TXDataOperationContext.Current.CreateCriteria<TProduct>(Query).List;

Now I try to do something like this - of course is not working :)

> procedure TForm1.btnViewProductsClick(Sender: TObject);
> var qry: TXDataQuery;
> begin
>   var Client := GetClient;
>   var EasyService := Client.Service<IEasyService>;
>   qry := TXDataQuery.Create;
>   var list := EasyService.QueryProducts(qry);
>   xdsView.Load;
>   Client.Free;
> end;

The question is - how do I use the list that the server returns?

I'm not sure if you checked the documentation about creating XData client app using Web Core? The commented code you provided is for regular Delphi applications, not Web Core. Here is the chapter:

That's correct - i have to use a Windows application to get the data into a dataset.

I'm not using WebCore,

In this case you can use TAureliusDataset to bind the objects to the data-aware controls.
It's as simple as this:

  AureliusDataset1.SetSourceList(EasyService.QueryProducts(qry), True);

But be aware that TXDataClient object must not be destroyed while the dataset is open, otherwise it will destroy the returned objects and the dataset will try to use destroyed objects.

It works, thank you!

But I'm confused - why use TAureliusDataset? Isn't supposed to use with Aurelius and not XData?

Indeed, the name is misleading. It's a dataset that binds objects to data-aware controls. It just happens to be inside TMS Aurelius library. :slight_smile:

1 Like

This topic was automatically closed 60 minutes after the last reply. New replies are no longer allowed.