-
Notifications
You must be signed in to change notification settings - Fork 130
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
Total records found #34
Comments
Why not use LINQ (eg. |
From my own experience I'd like the ability to get the total count while filtering and paginating. Though, if I'm wrong I'd be pretty happy as I'm currently doing this as a workaround:
|
You're close, here's a better version: var questions = _context.Questions.AsNoTracking();
questions = _sieveProcessor.Apply(sieveModel, questions, applyPagination: false);
Request.HttpContext.Response.Headers.Add("X-Total-Count", questions.Count().ToString());
questions = _sieveProcessor.Apply(sieveModel, questions, applyFiltering: false, applySorting: false); // Only applies pagination
return Ok(questions); You filter/sort then apply pagination once you get the count. That's actually how you're intendend to do it, not just a workaround. Tell me if you find a problem with this approach otherwise close the issue :). |
Ah, that's much nicer than duplicating the query! |
Hey , reviving this with a question to @Biarity , how was it planned to use Sieve in an API without knowing the total number of pages? There is also not a "hasPrevPage" and "hasNextPage" kind of data. |
Yeah I do think this should be core functionality. But the work-around works for me. |
Is there or is it planned to get total number of records found by filter?
Thanks
The text was updated successfully, but these errors were encountered: