Using Microsoft's Auto generated OData Connected Service -vs- Calling OData endpoints directly. Which is preferred? (Blazor &.Net 8)

1 Answer 9 Views
General Discussions Grid
John
Top achievements
Rank 1
John asked on 09 May 2024, 05:36 PM

I have a dozen OData Endpoints that provide all my data access. I am currently using the autogenerated OData Connected Service that uses the Microsoft OData Client to access the endpoints from services in my Blazor ServerSide app. 

The Telerik Blazor components seem to be geared around using Telerik.DataSource & Telerik.DataSource.Extensions to access the OData Endpoints directly.

Is there a best practice or method for accessing OData Endpoints with Telerik components? 

 

Thanks

1 Answer, 1 is accepted

Sort by
1
Accepted
Dimo
Telerik team
answered on 14 May 2024, 07:24 AM

Hello John,

The Telerik.Blazor.Extensions namespace provides a ToODataString() method, which can help you get data from an OData endpoint. The method basically serializes the paging, sorting and filtering criteria from the OnRead event argument (args.Request). You can then append the string to the endpoint URL. Here is a REPL example.

You will notice that ToODataString() doesn't support grouping and there is a feature request about that. (I voted for it on your behalf.) So, you can either append grouping information to the OData string manually, or fetch all data items initially, bind the Grid with a Data parameter and let the Grid group on its own.

On a side note, ToDataSourceResult() from Telerik.DataSource.Extensions is a built-in enhancement, but it's not required to always use it. Another option is to get the request parameters from the DataSourceRequest object and for example, use standard query methods Skip(), Take(), Where(), OrderBy(), etc.

Regards,
Dimo
Progress Telerik

Stay tuned by visiting our public roadmap and feedback portal pages! Or perhaps, if you are new to our Telerik family, check out our getting started resources!
Tags
General Discussions Grid
Asked by
John
Top achievements
Rank 1
Answers by
Dimo
Telerik team
Share this question
or