Beispiel #1
0
        public override FeedIterator <T> CreateItemQuery <T>(
            CosmosSqlQueryDefinition sqlQueryDefinition,
            int maxConcurrency,
            int?maxItemCount                   = null,
            string continuationToken           = null,
            QueryRequestOptions requestOptions = null)
        {
            requestOptions = requestOptions ?? new QueryRequestOptions();
            requestOptions.EnableCrossPartitionQuery = true;
            requestOptions.RequestContinuation       = continuationToken;
            requestOptions.MaxItemCount   = maxItemCount;
            requestOptions.MaxConcurrency = maxConcurrency;

            CosmosQueryExecutionContext cosmosQueryExecution = new CosmosQueryExecutionContextFactory(
                client: this.queryClient,
                resourceTypeEnum: ResourceType.Document,
                operationType: OperationType.Query,
                resourceType: typeof(T),
                sqlQuerySpec: sqlQueryDefinition.ToSqlQuerySpec(),
                queryRequestOptions: requestOptions,
                resourceLink: this.LinkUri,
                isContinuationExpected: true,
                allowNonValueAggregateQuery: true,
                correlatedActivityId: Guid.NewGuid());

            return(new FeedIteratorCore <T>(
                       maxItemCount,
                       continuationToken,
                       requestOptions,
                       this.NextResultSetAsync <T>,
                       cosmosQueryExecution));
        }
        public override CosmosResultSetIterator CreateItemQueryAsStream(
            CosmosSqlQueryDefinition sqlQueryDefinition,
            int maxConcurrency,
            object partitionKey      = null,
            int?maxItemCount         = null,
            string continuationToken = null,
            CosmosQueryRequestOptions requestOptions = null)
        {
            requestOptions = requestOptions ?? new CosmosQueryRequestOptions();
            requestOptions.MaxConcurrency            = maxConcurrency;
            requestOptions.EnableCrossPartitionQuery = true;
            requestOptions.RequestContinuation       = continuationToken;
            requestOptions.MaxItemCount = maxItemCount;
            requestOptions.PartitionKey = partitionKey;

            IDocumentQueryExecutionContext documentQueryExecution = new CosmosQueryExecutionContextFactory(
                client: this.queryClient,
                resourceTypeEnum: ResourceType.Document,
                operationType: OperationType.Query,
                resourceType: typeof(CosmosQueryResponse),
                sqlQuerySpec: sqlQueryDefinition.ToSqlQuerySpec(),
                queryRequestOptions: requestOptions,
                resourceLink: this.container.LinkUri,
                isContinuationExpected: true,
                allowNonValueAggregateQuery: true,
                correlatedActivityId: Guid.NewGuid());

            return(new CosmosResultSetIteratorCore(
                       maxItemCount,
                       continuationToken,
                       requestOptions,
                       this.QueryRequestExecutor,
                       documentQueryExecution));
        }
Beispiel #3
0
        public override CosmosResultSetIterator CreateItemQueryAsStream(
            CosmosSqlQueryDefinition sqlQueryDefinition,
            int maxConcurrency,
            object partitionKey      = null,
            int?maxItemCount         = null,
            string continuationToken = null,
            CosmosQueryRequestOptions requestOptions = null)
        {
            requestOptions = requestOptions ?? new CosmosQueryRequestOptions();
            requestOptions.maxConcurrency            = maxConcurrency;
            requestOptions.EnableCrossPartitionQuery = true;

            FeedOptions feedOptions = requestOptions.ToFeedOptions();

            feedOptions.RequestContinuation = continuationToken;
            feedOptions.MaxItemCount        = maxItemCount;
            if (partitionKey != null)
            {
                PartitionKey pk = new PartitionKey(partitionKey);
                feedOptions.PartitionKey = pk;
            }

            DocumentQuery <CosmosQueryResponse> documentQuery = (DocumentQuery <CosmosQueryResponse>) this.client.DocumentClient.CreateDocumentQuery <CosmosQueryResponse>(
                collectionLink: this.container.LinkUri.OriginalString,
                feedOptions: feedOptions,
                querySpec: sqlQueryDefinition.ToSqlQuerySpec());

            return(new CosmosResultSetIteratorCore(
                       maxItemCount,
                       continuationToken,
                       requestOptions,
                       this.QueryRequestExecutor,
                       documentQuery));
        }
Beispiel #4
0
        public override CosmosResultSetIterator <T> CreateItemQuery <T>(
            CosmosSqlQueryDefinition sqlQueryDefinition,
            int maxConcurrency,
            int?maxItemCount         = null,
            string continuationToken = null,
            CosmosQueryRequestOptions requestOptions = null,
            CancellationToken cancellationToken      = default(CancellationToken))
        {
            CosmosQueryRequestOptions options = requestOptions ?? new CosmosQueryRequestOptions();

            options.maxConcurrency            = maxConcurrency;
            options.EnableCrossPartitionQuery = true;

            return(new CosmosDefaultResultSetIterator <T>(
                       maxItemCount,
                       continuationToken,
                       options,
                       this.NextResultSetAsync <T>,
                       sqlQueryDefinition.ToSqlQuerySpec()));
        }
Beispiel #5
0
        public override CosmosResultSetIterator <T> CreateItemQuery <T>(
            CosmosSqlQueryDefinition sqlQueryDefinition,
            object partitionKey,
            int?maxItemCount         = null,
            string continuationToken = null,
            CosmosQueryRequestOptions requestOptions = null)
        {
            CosmosQueryRequestOptions options = requestOptions ?? new CosmosQueryRequestOptions();

            if (partitionKey != null)
            {
                PartitionKey pk = new PartitionKey(partitionKey);
                options.PartitionKey = pk;
            }

            options.EnableCrossPartitionQuery = false;

            return(new CosmosDefaultResultSetIterator <T>(
                       maxItemCount,
                       continuationToken,
                       options,
                       this.NextResultSetAsync <T>,
                       sqlQueryDefinition.ToSqlQuerySpec()));
        }