NextPageLink set to null when top query option is set

Topics: ASP.NET Web API
Apr 30, 2013 at 9:10 PM
Edited Apr 30, 2013 at 9:13 PM
I have a Web API method that specifies ODataQuerySettings.PageSize and returns a PageResult<T>. As I understand it, including the PageSize value allows the NextPageLink to be returned 1. However, I've noticed that the NextPageLink is set to null if I include a top query option in the request.

e.g. http://localhost:60604/employees?$inlinecount=allpages&$top=5&$skip=5

(NextPageLink=null)

e.g. http://localhost:60604/employees?$inlinecount=allpages&$skip=5

(NextPageLink=http://localhost:60604/employees?$inlinecount=allpages&$skip=10)

I'd like to be able to include the top option in the request and have the NextPageLink reflect that page size. I understand you wouldn't want to overwrite the PageSize setting to prevent abuse, but having the page size locked down in the service seems restrictive and not allowing a caller to specify a top option won't allow them to take advantage of the NextPageLink.
Apr 30, 2013 at 9:46 PM
I continued reviewing the source and noticed this comment:
// There is no next page if the $top query option's value is less than or equal to the page size.
I had originally set ODataQuerySettings.PageSize to 5 and was passing $top=5. Once I changed the request to pass $top=20 I got the following:

NextPageLink=http://localhost:60604/employees?$inlinecount=allpages&$top=10&$skip=15

Sorry for the confusion - makes sense now.