Using OData with Queries That are Set with a Top Number of Rows
Business Central queries include the TopNumberOfRows Property and TopNumberOfRows Method that can be used to specify the maximum number of rows to include in the resulting dataset. The Business Central Server includes the Max Page Size setting for OData that specifies the maximum number of entities returned per page of OData results. The default value is 20,000.
To ensure that the OData results include the correct number of entities when you are using a query that is set with a top number of rows, you should set the Max Page Size value greater than the value that is set by the TopNumberOfRows property and TopNumberOfRows method. Otherwise, the TopNumberOfRows property and TopNumberOfRows method are ignored and the query dataset will be returned in the OData results.
Typically, the TopNumberOfRows property or TopNumberOfRows method are used to return a relatively small number of entities, such as the top five, ten, or 100 entities. Therefore, in most cases, the value of the TopNumberOfRows property and TopNumberOfRows method will be less than the Max Page Size, so that you will not have to change the Max Page Size setting.
Tip
In HTTP requests, it can be beneficial to use odata.maxpagesize
instead of the system query options $top
and $skip
. For instance, odata.maxpagesize
automatically includes nextlink
in the response, which lets you continuously retrieve a large dataset in limited chunks.
For information about how to change the Max Page Size setting, see Configuring Business Central Server and Server-Driven Paging in OData Web Services.