public static async Task <TryCatch <IDocumentQueryExecutionComponent> > TryCreateAsync( ExecutionEnvironment executionEnvironment, IReadOnlyList <AggregateOperator> aggregates, IReadOnlyDictionary <string, AggregateOperator?> aliasToAggregateType, IReadOnlyList <string> orderedAliases, bool hasSelectValue, CosmosElement continuationToken, Func <CosmosElement, Task <TryCatch <IDocumentQueryExecutionComponent> > > tryCreateSourceAsync) { if (tryCreateSourceAsync == null) { throw new ArgumentNullException(nameof(tryCreateSourceAsync)); } TryCatch <IDocumentQueryExecutionComponent> tryCreateAggregate; switch (executionEnvironment) { case ExecutionEnvironment.Client: tryCreateAggregate = await ClientAggregateDocumentQueryExecutionComponent.TryCreateAsync( aggregates, aliasToAggregateType, orderedAliases, hasSelectValue, continuationToken, tryCreateSourceAsync); break; case ExecutionEnvironment.Compute: tryCreateAggregate = await ComputeAggregateDocumentQueryExecutionComponent.TryCreateAsync( aggregates, aliasToAggregateType, orderedAliases, hasSelectValue, continuationToken, tryCreateSourceAsync); break; default: throw new ArgumentException($"Unknown {nameof(ExecutionEnvironment)}: {executionEnvironment}."); } return(tryCreateAggregate); }
/// <summary> /// Creates a AggregateDocumentQueryExecutionComponent. /// </summary> /// <param name="executionEnvironment">The environment to execute on.</param> /// <param name="queryClient">The query client.</param> /// <param name="aggregates">The aggregates.</param> /// <param name="aliasToAggregateType">The alias to aggregate type.</param> /// <param name="orderedAliases">The ordering of the aliases.</param> /// <param name="hasSelectValue">Whether or not the query has the 'VALUE' keyword.</param> /// <param name="requestContinuation">The continuation token to resume from.</param> /// <param name="createSourceCallback">The callback to create the source component that supplies the local aggregates.</param> /// <returns>The AggregateDocumentQueryExecutionComponent.</returns> public static async Task <IDocumentQueryExecutionComponent> CreateAsync( ExecutionEnvironment executionEnvironment, CosmosQueryClient queryClient, AggregateOperator[] aggregates, IReadOnlyDictionary <string, AggregateOperator?> aliasToAggregateType, IReadOnlyList <string> orderedAliases, bool hasSelectValue, string requestContinuation, Func <string, Task <IDocumentQueryExecutionComponent> > createSourceCallback) { IDocumentQueryExecutionComponent aggregateDocumentQueryExecutionComponent; switch (executionEnvironment) { case ExecutionEnvironment.Client: aggregateDocumentQueryExecutionComponent = await ClientAggregateDocumentQueryExecutionComponent.CreateAsync( queryClient, aggregates, aliasToAggregateType, orderedAliases, hasSelectValue, requestContinuation, createSourceCallback); break; case ExecutionEnvironment.Compute: aggregateDocumentQueryExecutionComponent = await ComputeAggregateDocumentQueryExecutionComponent.CreateAsync( queryClient, aggregates, aliasToAggregateType, orderedAliases, hasSelectValue, requestContinuation, createSourceCallback); break; default: throw new ArgumentException($"Unknown {nameof(ExecutionEnvironment)}: {executionEnvironment}."); } return(aggregateDocumentQueryExecutionComponent); }