OData / OData/AspNetCoreOData

Request.GetNextPage link ignores maxPageSize Preference header

Open
#143 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
505
Forks
186
PR merge metrics
No merged PRs in 30d

Description

!-- markdownlint-disable MD002 MD041 -->

I am trying to implement pagination with nextpage link. So I want to read X number of records on each page until there are no more records.

Assemblies affected

Microsoft.AspNetCore.OData, Version=7.3.0.0

Reproduce steps

With odata.MaxPageSize= 10

In Startup

 var builder = new RouteBuilder(app);
 builder.Select().OrderBy().Filter().SkipToken();
private static readonly int pageSize = 20;
private static ODataQuerySettings querySettings = new ODataQuerySettings()
{
    PageSize = pageSize,
    EnsureStableOrdering = true,
};

public static PagedResponse<TOut> GetPageResult<TIn, TOut>(IQueryable<TOut> models, ODataQueryOptions<TIn> queryOptions, HttpRequest request)
{
    var results = queryOptions.ApplyTo(models, querySettings) as IEnumerable<TOut>;

    return new PagedResponse<TOut>(results, request.GetNextPageLink(pageSize), 
    request.HttpContext.ODataFeature().TotalCount);
}
Expected result

Results should have 10 elements and GetNextPageLink should use MaxPageSize preference header to generate a skiptoken.

Actual result

Results has 10 elements but GetNextPageLink ignores MaxPageSize and does not generate a skipToken

Additional detail

Maybe overload should be used, but how to create objectToSkipTokenValue
public static Uri GetNextPageLink(this HttpRequest request, int pageSize, object instance, Func<object, string> objectToSkipTokenValue);

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the supplied GetNextPageLink call and the ODataQuerySettings PageSize/MaxPageSize behavior, then run the reproduction using Microsoft.AspNetCore.OData 7.3.0. Compare the generated next-page URI with the expected request and verify that it honors the preference header and includes a skiptoken when required.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
api, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.