/// <summary> /// Call this method to initialize the environment to support server-driven paging. /// </summary> /// <param name="context">The values of the Prefer HTTP header.</param> public void InitializeServerDrivenPaging(PreferenceContext context) { if (context == null) { throw Utility.BuildException(HttpStatusCode.InternalServerError); } if (this.Target.TypeKind == EdmTypeKind.Collection && this.Target.ElementTypeKind == EdmTypeKind.Entity) { // If the current request contains odata.maxpagesize preference if (context.MaxPageSize.HasValue) { var clientSize = context.MaxPageSize.Value; // The client might set odata.maxpagesize as zero or negative if (clientSize < 1) { clientSize = ServiceConstants.DefaultPageSize; } this.appliedPageSize = (clientSize > ServiceConstants.DefaultPageSize) ? ServiceConstants.DefaultPageSize : clientSize; } else { this.appliedPageSize = ServiceConstants.DefaultPageSize; } } }
/// <summary> /// Call this method to detect whether the current request need to track changes. /// </summary> /// <param name="context">The values of the Prefer HTTP header.</param> public void InitializeTrackingChanges(PreferenceContext context) { if (context == null) { throw Utility.BuildException(HttpStatusCode.InternalServerError); } this.TrackingChanges = context.TrackingChanges || this.skipToken.TrackingChanges; }
/// <summary> /// Call this method to detect whether the current request need to track changes. /// </summary> /// <param name="context">The values of the Prefer HTTP header.</param> public void InitializeTrackingChanges(PreferenceContext context) { if (context == null) throw Utility.BuildException(HttpStatusCode.InternalServerError); this.TrackingChanges = context.TrackingChanges || this.skipToken.TrackingChanges; }
/// <summary> /// Call this method to initialize the environment to support server-driven paging. /// </summary> /// <param name="context">The values of the Prefer HTTP header.</param> public void InitializeServerDrivenPaging(PreferenceContext context) { if (context == null) throw Utility.BuildException(HttpStatusCode.InternalServerError); if (this.Target.TypeKind == EdmTypeKind.Collection && this.Target.ElementTypeKind == EdmTypeKind.Entity) { // If the current request contains odata.maxpagesize preference if (context.MaxPageSize.HasValue) { var clientSize = context.MaxPageSize.Value; // The client might set odata.maxpagesize as zero or negative if (clientSize < 1) { clientSize = ServiceConstants.DefaultPageSize; } this.appliedPageSize = (clientSize > ServiceConstants.DefaultPageSize) ? ServiceConstants.DefaultPageSize : clientSize; } else { this.appliedPageSize = ServiceConstants.DefaultPageSize; } } }