/// <summary> /// Fill the CosmosRequestMessage headers with the set properties /// </summary> /// <param name="request">The <see cref="RequestMessage"/></param> internal override void PopulateRequestOptions(RequestMessage request) { if (this.PartitionKey != null && request.ResourceType != ResourceType.Document) { throw new ArgumentException($"{nameof(this.PartitionKey)} can only be set for item operations"); } // Cross partition is only applicable to item operations. if (this.PartitionKey == null && !this.IsEffectivePartitionKeyRouting && request.ResourceType == ResourceType.Document) { request.Headers.Add(HttpConstants.HttpHeaders.EnableCrossPartitionQuery, bool.TrueString); } RequestOptions.SetSessionToken(request, this.SessionToken); RequestOptions.SetConsistencyLevel(request, this.ConsistencyLevel); // Flow the pageSize only when we are not doing client eval if (this.MaxItemCount.HasValue) { request.Headers.Add(HttpConstants.HttpHeaders.PageSize, this.MaxItemCount.ToString()); } if (this.MaxConcurrency.HasValue && this.MaxConcurrency > 0) { request.Headers.Add(HttpConstants.HttpHeaders.ParallelizeCrossPartitionQuery, bool.TrueString); } if (this.EnableScanInQuery.HasValue && this.EnableScanInQuery.Value) { request.Headers.Add(HttpConstants.HttpHeaders.EnableScanInQuery, bool.TrueString); } if (this.EnableLowPrecisionOrderBy != null) { request.Headers.Add(HttpConstants.HttpHeaders.EnableLowPrecisionOrderBy, this.EnableLowPrecisionOrderBy.ToString()); } if (this.ResponseContinuationTokenLimitInKb != null) { request.Headers.Add(HttpConstants.HttpHeaders.ResponseContinuationTokenLimitInKB, this.ResponseContinuationTokenLimitInKb.ToString()); } if (this.CosmosSerializationOptions != null) { request.Headers.Add(HttpConstants.HttpHeaders.ContentSerializationFormat, this.CosmosSerializationOptions.ContentSerializationFormat); } base.PopulateRequestOptions(request); }
/// <summary> /// Fill the CosmosRequestMessage headers with the set properties /// </summary> /// <param name="request">The <see cref="RequestMessage"/></param> internal override void PopulateRequestOptions(RequestMessage request) { request.Headers.Add(HttpConstants.HttpHeaders.ContentType, MediaTypes.QueryJson); request.Headers.Add(HttpConstants.HttpHeaders.IsQuery, bool.TrueString); request.Headers.Add(HttpConstants.HttpHeaders.EnableCrossPartitionQuery, bool.TrueString); RequestOptions.SetSessionToken(request, this.SessionToken); RequestOptions.SetConsistencyLevel(request, this.ConsistencyLevel); // Flow the pageSize only when we are not doing client eval if (this.MaxItemCount.HasValue) { request.Headers.Add(HttpConstants.HttpHeaders.PageSize, this.MaxItemCount.ToString()); } if (this.MaxConcurrency.HasValue && this.MaxConcurrency > 0) { request.Headers.Add(HttpConstants.HttpHeaders.ParallelizeCrossPartitionQuery, bool.TrueString); } if (this.EnableScanInQuery.HasValue && this.EnableScanInQuery.Value) { request.Headers.Add(HttpConstants.HttpHeaders.EnableScanInQuery, bool.TrueString); } if (this.EnableLowPrecisionOrderBy != null) { request.Headers.Add(HttpConstants.HttpHeaders.EnableLowPrecisionOrderBy, this.EnableLowPrecisionOrderBy.ToString()); } if (this.ResponseContinuationTokenLimitInKb != null) { request.Headers.Add(HttpConstants.HttpHeaders.ResponseContinuationTokenLimitInKB, this.ResponseContinuationTokenLimitInKb.ToString()); } if (this.CosmosSerializationOptions != null) { request.Headers.Add(HttpConstants.HttpHeaders.ContentSerializationFormat, this.CosmosSerializationOptions.ContentSerializationFormat); } base.PopulateRequestOptions(request); }
/// <summary> /// Fill the CosmosRequestMessage headers with the set properties /// </summary> /// <param name="request">The <see cref="RequestMessage"/></param> internal override void PopulateRequestOptions(RequestMessage request) { if (this.PreTriggers != null && this.PreTriggers.Any()) { request.Headers.Add(HttpConstants.HttpHeaders.PreTriggerInclude, this.PreTriggers); } if (this.PostTriggers != null && this.PostTriggers.Any()) { request.Headers.Add(HttpConstants.HttpHeaders.PostTriggerInclude, this.PostTriggers); } if (this.IndexingDirective != null && this.IndexingDirective.HasValue) { request.Headers.Add(HttpConstants.HttpHeaders.IndexingDirective, this.IndexingDirective.Value.ToString()); } RequestOptions.SetSessionToken(request, this.SessionToken); RequestOptions.SetConsistencyLevel(request, this.ConsistencyLevel); base.PopulateRequestOptions(request); }