At last I managed to implement Task-based
calling of Data Services
I have prepared a small demo application that exposes Sofia Car Rental
database (which can be found in the attached zip file) through Data Services v3
(same code should work for v2
There you can find the code that does the magic:
async Task<IEnumerable<Customer>> LoadDataUsingTasks()
DataServiceQuery<Customer> query = dataModel.Customers;
var task = Task.Factory.FromAsync(
The most important bit is Line 5
- I am creating a task using Task.FromAsync(...)
method that is introduced to handle exactly this situation.
I have added two more examples that handle consuming data using the Begin/End API
and the "default" API
that uses LoadAsync(...)
method so you can compare them and choose the one that suits you most.
Please note that the provided code is "barebone
" and requires polishing and handling of errors.
I believe based on this sample you will be able to create a wrapper around the generated service client proxy in order to hide these implementation details.
Thank you for your patience! We will be happy if you share your feedback on the provided code.
the Telerik team
Telerik OpenAccess ORM Meets ASP.NET Web API. Read more.