-
Notifications
You must be signed in to change notification settings - Fork 32
Server Driven Paging
To use responses that include only a partial set of the items identified by the request indicate maximum page size through the invoke method OeRequestHeaders.SetMaxPageSize(int maxPageSize). The service serializes the returned continuation token into the $skiptoken query option and returns it as part of the next link (@odata.nextLink)to the client. If request returns result set sorted by nullable database column, should set OeDataAdapter.IsDatabaseNullHighestValue (SQLite, MySql, Sql Server set false, for PostgreSql, Oracle set true), or mark property RequiredAttribute.
//Create adapter data access, where OrderContext your DbContext
DbContextOptions contextOptions = OrderContextOptions.Create(useRelationalNulls: true);
var dataAdapter = new OeEfCoreDataAdapter<Model.OrderContext>(contextOptions)
{
IsDatabaseNullHighestValue = true //PostgreSql
};
//Create query parser
var parser = new OeParser(new Uri("http://dummy"), dataAdapter.BuildEdmModel());
//Query
var uri = new Uri("http://dummy/Orders?$select=Name&$orderby=Date");
//Set max page size
OeRequestHeaders requestHeaders = OeRequestHeaders.JsonDefault.SetMaxPageSize(10);
//The result of the query
var response = new MemoryStream();
//Execute query
await parser.ExecuteGetAsync(uri, requestHeaders, response, CancellationToken.None);
To use server side paging in expanded to-many navigation properties, should use Model Bound Attributes method Page(maxTopValue: 2, pageSizeValue: -1) with parameter pageSizeValue set -1.
//Create model bound provider
var modelBoundFluentBuilder = new Query.Builder.OeModelBoundFluentBuilder(edmModel);
modelBoundFluentBuilder.EntitySet<Model.Order>("Orders").EntityType
.Page(2, -1)
.Property(o => o.Items).Page(2, -1);
OeModelBoundProvider modelBoundProvider = modelBoundFluentBuilder.BuildProvider();