Unplanned
Last Updated: 03 Jan 2025 08:31 by ADMIN
ERCANPOLAT
Created on: 27 Dec 2024 21:29
Category: UI for ASP.NET Core
Type: Feature Request
2
ToDataSourceResultAsync is not actually Async

In the example below products is actually DbSet<Product>

public async Task<ActionResult> Products_Read([DataSourceRequest]DataSourceRequest request)
{
    using (var northwind = new SampleEntities())
    {
        IQueryable<Product> products = northwind.Products;
        DataSourceResult result = await products.ToDataSourceResultAsync(request);
        return Json(result);
    }
}

Under the hood the ToDataSourceResultAsync call is executed inside Task.Run

And that Task.Run is calling sync methods of IQueryable which means EntityframeworkCore queries are not taking place with async I/O

0 comments