AspNetCoreOData
AspNetCoreOData copied to clipboard
[Improvement] Add support for query batching when using $count=true
Given "Microsoft.AspNetCore.OData" Version="8.2.3" and async OData controller:
[EnableQuery]
public async Task<IAsyncEnumerable<Order>> Get()
{
IQueryable<Order> queryable = _context.Orders;
return queryable.AsAsyncEnumerable();
}
When I execute a query then I see 2 separate calls performed
- A synchronous request to fetch total count (the synchronous nature is itself another bug as described here: https://github.com/OData/WebApi/issues/2325
- An asynchronous request fetching the actual data
This resulted into 2 separate db roundtrips, however it could have been optimized by batching these 2 queries together as for example is possible via Entity Framework Plus Query Future: https://entityframework-plus.net/ef-core-query-future
Batching such requests together would reduce the amount of roundtrips to db and improve performance.