Webapi: .net core '@odata.nextLink' support

Created on 9 Jan 2018  路  3Comments  路  Source: OData/WebApi

I am trying to use odata on my .net core 2.0.0 app.

With this request, http://localhost:5021/api/OutboxDespatch?skip=1&$top=2&$count=true

I got a response like below.

'nextLink' is not supported or i am doing something wrong?

Thanks!

image

featurnetcore question

Most helpful comment

Is it possible that we can get that without PageSize on the server based on $skip and $top that the client sends? Right now this is NOT client driven - some clients are prepared to deal with a lot of data, some not. Some want to only show a page and can switch how many items that is.

The static PageSize server side as a maximum - great,- but it should not be a requirement. If there is one line more than waht the user asks for ($skip, $top) then the next link is generated.

All 3 comments

@suadev - There is an article on server-driven paging here: https://docs.microsoft.com/en-us/aspnet/web-api/overview/odata-support-in-aspnet-web-api/supporting-odata-query-options#server-paging

Basically, if you add:

[EnableQuery(PageSize = 2)]
to the controller method, then WebApi will automatically return 2 results (when asked for more than 2) and provide the nextlink automatically.

If you want to enable your own method for next links, you can use a PagedResult return type and specify the nextLink in the constructor.

FYI, I think it's a typo but the example Url is missing the "$" in front of Skip.

Is it possible that we can get that without PageSize on the server based on $skip and $top that the client sends? Right now this is NOT client driven - some clients are prepared to deal with a lot of data, some not. Some want to only show a page and can switch how many items that is.

The static PageSize server side as a maximum - great,- but it should not be a requirement. If there is one line more than waht the user asks for ($skip, $top) then the next link is generated.

@NetTecture I really agree with you.

It would be benificial to have a DefaultPageSize and a MaxPageSize so that the client can choose to override the defaults if it can handle the load while the server side still may refuse the request if the query is outside the PageSize scope.

Was this page helpful?
0 / 5 - 0 ratings