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

Enable pagination result with QueryResult<T> #257

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

marinasundstrom
Copy link

This adds the ability to get the current Total and TotalPage in the result of a query, by adding the QueryResult<T> class.

I chose to go the easy way, similar to other places in the code, parse the headers of the last request, and put them and the resulting items into QueryResult<T>.

The QueryResult is a custom collection class that substitutes the use of IEnumerable<T> as return type for IQueryOperation<TClass, QClass>.Query(...). It implements IEnumerable<T> so enumeration will still be possible.

XML documentation TBA

I will remove the Test project

@ThomasPe
Copy link
Member

Hey @marinasundstrom, so sorry for not looking at this any sooner! Are you still interested in getting this merged?
@navjot50 any thoughts on this implementation?

@navjot50
Copy link
Contributor

Hi @ThomasPe I briefly worked on the post count feature and I have some draft code here https://github.com/navjot50/WordPressPCL/tree/feature-posts-count. Basically, here I didn't introduce a custom result but rather introduced a new interface ICountOperation with a GetCountAsync where the implementation sends a HEAD request which just returns response headers without any payload (lightweight request) and then it returns the value of X-WP-Total header. This will be the minimum solution.

However, since we can introduce breaking changes in release2.0 we can go also go with a more custom result depending on what the library users want the most.

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

Successfully merging this pull request may close these issues.

None yet

3 participants