Hi
How to use async/await loading patterns (https://docs.microsoft.com/en-us/aspnet/core/data/ef-mvc/intro#asynchronous-code) with DataSourceLoader?
I'll explain.
Here is a sample https://js.devexpress.com/Documentation/Guide/ASP.NET_MVC_Controls/Data_Binding
Specifically this part:
public object GetOrders(DataSourceLoadOptions loadOptions)
{
return DataSourceLoader.Load(_nwind.Orders, loadOptions);
}
We get a request, parse it with model binding and using DataSourceLoading process it (filter, sort, group, etc.).
The last part (loading) might take some considerable time because of database/network access.
I suppose async/await is used to accomodate for this and free some resources for processing with other threads while busy with this request.
But how to do this using DataSourceLoader? Or perhaps there are other ways?
We have a WebApi server which should process requests from client using DevExtreme components (like DataGrid).
I guess DataSourceLoadOptions works just for that, but it's not asynchronous.
One way to do it is to wrap the loading part into a Task.Start() and await for it, but it doesn't seems right to me, because using EF Core in other threads requires creation of new db context per thread.
ASP Net Core 2.0 has some caching for db context creations and if we just create a new one per request every time, this caching won't be used much.
Is there any way around this or i'm just missing something from the docs and we can safely wrap DataSourceLoader.Load() into a Task.Run() ?
Thanks.