Paging and sorting in custom service brokers
K2 Service Brokers handle paging and sorting of data that is returned from services, by default the data is sorted by the service broker however it is possible to sort data before it is returned to the custom service broker (handled paging and sorting). When handled paging and sorting is done the built-in functionality for paging and sorting on the service broker will be bypassed and data will be sorted before being passed and only data within the required page will be passed to the service broker.
Enabling this functionality is achieved by using the HandledPaging property found in SourceCode.SmartObjects.Services.ServiceSDK.ServiceAssemblyBase.
The HandledPaging property must be set to True and use the following properties found in SourceCode.SmartObjects.Services.ServiceSDK.Objects.ServicePackage to set paging and sorting details.
OrderBy : contains the service instance column and the sorting order which will be received from the client side.
PageNumber: specifies the current page.
PageSize: The number of records in the page.
StartRecord: The first record in the page.
MaxRecord: Maximum number of records in the page.
The advantage of handled paging and sorting is that performance is increased since only the required data is passed back to the service broker and there is no extra step of sorting being done at the service broker level.