Hi,
I'm trying to invoke a service operation with a query. The Documentation (Service Operations | TMS XData documentation ) says I can do this with the TXDataClient and the QueryBuilder
IMyService = interface(IInvokable)
[HttpGet] function List(Query: TXDataQuery): TList<TCustomer>;
Customer := Client.Service<IMyService>.List(
CreateQuery.From(TCustomer)
.Filter(Linq['Name'] eq 'Foo')
.OrderBy('Name')
.Top(10).Skip(30)
.QueryString
);
But the Client doesn't compile this.... Incompatible type string and TXDataQuery.
What I'm missing?
Thank you!
wlandgraf
(Wagner Landgraf)
March 13, 2025, 5:55pm
2
That's because you are calling directly using the interface, which of course requires you to pass a TXDataQuery object.
Thus that's what you can do, simply pass the XDataQuery object:
QueryReq := TXDataQuery.Create('Name eq ''foo''', 'Name', 10, 30);
XClient.ReturnedEntities.Add(QueryReq);
Query := XClient.Service<IMyService>.List(QueryReq);
I agree, though, that the XData Query Builder could also return a TXDataQuery object In addition to a string, for those cases.
Thank you for your reply.
Hmm.. maybe the documentation is wrong? The code above is from the the current documentation.
wlandgraf
(Wagner Landgraf)
March 14, 2025, 6:04pm
4
Indeed, it's wrong. We will fix it.
wlandgraf
(Wagner Landgraf)
April 5, 2025, 12:14am
5
We have now added the Build
method to TXDataQueryBuilder
to allow creating a TXDataQuery
object from it.
The documentation has been updated accordingly, here is how to use it:
Query := CreateQuery
.From(TCustomer)
.Filter(Linq['Name'] = 'Foo')
.OrderBy('Name')
.Top(10).Skip(30)
.Build;
XClient.ReturnedEntities.Add(Query);
Customer := Client.Service<IMyService>.List(Query);
Such improvements will be available in version 5.20.
system
(system)
Closed
April 6, 2025, 12:14am
6
This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.