Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add guidance on retrieving TotalCount with paginated query #4620

Closed
adamal opened this issue Jan 10, 2024 · 1 comment
Closed

Add guidance on retrieving TotalCount with paginated query #4620

adamal opened this issue Jan 10, 2024 · 1 comment

Comments

@adamal
Copy link

adamal commented Jan 10, 2024

When paging queried data, we often need to know the totalt count of the filtered data before paging.
The straight-forward approach causes two roundtrips to the database. One for the data one for the count.

In Dapper, this is easily achievable using QueryMultiple.

On Stackoverflow I have only found very old or low quality answers, with solutions that are hacky at best. Chat-GPT provides broken answers. Would be great if you could provide an authoritative answer. This specific article on paging seems an ideal location.


Document Details

Do not edit this section. It is required for learn.microsoft.com ➟ GitHub issue linking.

@roji
Copy link
Member

roji commented Jan 10, 2024

The main issue for batching multiple queries is dotnet/efcore#10879 that would be the analog to Dapper's QueryMultiple; unfortunately there isn't a great way to achieve that at the moment. It may be possible to fake it by folding the two queries into one, but I don't have an example ready (and it would probably mostly be a hack).

@ajcvickers ajcvickers closed this as not planned Won't fix, can't repro, duplicate, stale Jan 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants