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

            _collection.AggregateToCollection(pipeline, options, cancellationToken);
        }
        public OperationResult Execute(CancellationToken cancellationToken)
        {
            try
            {
                _collection.AggregateToCollection(_pipeline, _options, cancellationToken);

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

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

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

            _wrappedCollection.AggregateToCollection(filteredPipeline, options, cancellationToken);
        }