public Task AggregateToCollectionAsync <TResult>(
     PipelineDefinition <T, TResult> pipeline,
     AggregateOptions?options            = null,
     CancellationToken cancellationToken = default
     )
 {
     return(collection.AggregateToCollectionAsync(pipeline, options, cancellationToken));
 }
Esempio n. 2
0
 public override Task ToCollectionAsync(CancellationToken cancellationToken)
 {
     if (_session == null)
     {
         return(_collection.AggregateToCollectionAsync(_pipeline, _options, cancellationToken));
     }
     else
     {
         return(_collection.AggregateToCollectionAsync(_session, _pipeline, _options, cancellationToken));
     }
 }
        public Task AggregateToCollectionAsync <TResult>(
            PipelineDefinition <T, TResult> pipeline,
            AggregateOptions?options            = null,
            CancellationToken cancellationToken = default)
        {
            if (TryGetSession(out IClientSessionHandle? session))
            {
                return(AggregateToCollectionAsync(session, pipeline, options, cancellationToken));
            }

            return(_collection.AggregateToCollectionAsync(pipeline, options, cancellationToken));
        }
        public async Task <OperationResult> ExecuteAsync(CancellationToken cancellationToken)
        {
            try
            {
                await _collection.AggregateToCollectionAsync(_pipeline, _options, cancellationToken);

                return(OperationResult.FromResult(null));
            }
            catch (Exception exception)
            {
                return(OperationResult.FromException(exception));
            }
        }
        public override async Task <OperationResult> ExecuteAsync(CancellationToken cancellationToken)
        {
            var pipelineDefinition = new BsonDocumentStagePipelineDefinition <BsonDocument, BsonDocument>(_pipeline, BsonDocumentSerializer.Instance);

            try
            {
                if (_session == null)
                {
                    await _collection.AggregateToCollectionAsync(pipelineDefinition, _options, cancellationToken);
                }
                else
                {
                    await _collection.AggregateToCollectionAsync(_session, pipelineDefinition, _options, cancellationToken);
                }

                return(OperationResult.FromResult(null));
            }
            catch (Exception exception)
            {
                return(OperationResult.FromException(exception));
            }
        }
        public override Task AggregateToCollectionAsync <TResult>(PipelineDefinition <TDocument, TResult> pipeline, AggregateOptions options = null, CancellationToken cancellationToken = default(CancellationToken))
        {
            var filteredPipeline = CreateFilteredPipeline(pipeline);

            return(_wrappedCollection.AggregateToCollectionAsync(filteredPipeline, options, cancellationToken));
        }