Reputation: 11724
I am using blazor web app, .net version 8, and these packages to display SuperUser data dump using Quickgrid:
When using QuickGrid.EntityFrameworkAdapter, I use this code:
IQueryable<TagDTO> GetTagDTOsUnder600Query_EFAdapter { get; set; }
public async Task FetchTagsUnder600_EFAdapter()
{
GetTagDTOsUnder600Query_EFAdapter = _context.Tags
.Where(t => t.Id < 600)
.Select(t => new TagDTO(t.Id, t.TagName, t.Count));
}
And this is the sql which is sent to the database:
As you can see, the count query
is executed before my query.
In large database, the extra count query
is not good for performance.
Why it happens?
So far my solution was not using EF-Adapter, to prevent that count query
to execute.
But I thought maybe there is a way to disable it, or maybe it is not that bad when dealing with large database(even useful)?
I wanted to know others opinion and possible solution. Thank you.
Upvotes: 1
Views: 181
Reputation: 30177
Quick grid sends queries through a GridItemsProviderRequest<TGridItem>
and receives results in a GridItemsProviderResult<TGridItem>
which has the following properties:
Items
TotalItemCount
The count query gets the TotalItemCount
. I don't think there's any way around it.
GridItemsProviderRequest<TGridItem>
- https://learn.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.components.quickgrid.griditemsproviderrequest-1?view=aspnetcore-8.0GridItemsProviderResult<TGridItem>
- https://learn.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.components.quickgrid.griditemsproviderresult-1?view=aspnetcore-8.0Upvotes: 1