public async Task <BsonDocument> ExecuteCommandAsync(IWriteBinding binding, TimeSpan timeout = default(TimeSpan), CancellationToken cancellationToken = default(CancellationToken))
        {
            Ensure.IsNotNull(binding, "binding");
            var command   = CreateCommand();
            var operation = new WriteCommandOperation(_collectionNamespace.DatabaseNamespace, command, _messageEncoderSettings);

            return(await operation.ExecuteAsync(binding, timeout, cancellationToken));
        }
예제 #2
0
        /// <inheritdoc/>
        public async Task <BsonDocument> ExecuteAsync(IWriteBinding binding, CancellationToken cancellationToken)
        {
            Ensure.IsNotNull(binding, nameof(binding));
            var command   = CreateCommand();
            var operation = new WriteCommandOperation <BsonDocument>(_collectionNamespace.DatabaseNamespace, command, BsonDocumentSerializer.Instance, _messageEncoderSettings);

            return(await operation.ExecuteAsync(binding, cancellationToken).ConfigureAwait(false));
        }
예제 #3
0
        public async Task <BsonDocument> ExecuteAsync(IWriteBinding binding, TimeSpan timeout = default(TimeSpan), CancellationToken cancellationToken = default(CancellationToken))
        {
            Ensure.IsNotNull(binding, "binding");
            var command   = CreateCommand();
            var operation = new WriteCommandOperation("admin", command);

            return(await operation.ExecuteAsync(binding, timeout, cancellationToken));
        }
예제 #4
0
        /// <inheritdoc/>
        public Task <BsonDocument> ExecuteAsync(IWriteBinding binding, CancellationToken cancellationToken)
        {
            Ensure.IsNotNull(binding, "binding");
            var command   = CreateCommand();
            var operation = new WriteCommandOperation <BsonDocument>(CollectionNamespace.DatabaseNamespace, command, BsonDocumentSerializer.Instance, MessageEncoderSettings);

            return(operation.ExecuteAsync(binding, cancellationToken));
        }
        public async Task <BsonDocument> ExecuteAsync(IWriteBinding binding, TimeSpan timeout, CancellationToken cancellationToken)
        {
            Ensure.IsNotNull(binding, "binding");
            var command   = CreateCommand();
            var operation = new WriteCommandOperation(_databaseNamespace, command, _messageEncoderSettings);

            return(await operation.ExecuteAsync(binding, timeout, cancellationToken).ConfigureAwait(false));
        }
        private Task <BsonDocument> ExecuteUsingCommandAsync(IChannelSourceHandle channelSource, CancellationToken cancellationToken)
        {
            var databaseNamespace = _collectionNamespace.DatabaseNamespace;
            var command           = CreateCommand();
            var resultSerializer  = BsonDocumentSerializer.Instance;
            var operation         = new WriteCommandOperation <BsonDocument>(databaseNamespace, command, resultSerializer, _messageEncoderSettings);

            return(operation.ExecuteAsync(channelSource, cancellationToken));
        }
예제 #7
0
        /// <inheritdoc/>
        public async Task <BsonValue> ExecuteAsync(IWriteBinding binding, CancellationToken cancellationToken)
        {
            Ensure.IsNotNull(binding, "binding");
            var command   = CreateCommand();
            var operation = new WriteCommandOperation <BsonDocument>(_databaseNamespace, command, BsonDocumentSerializer.Instance, _messageEncoderSettings);
            var result    = await operation.ExecuteAsync(binding, cancellationToken).ConfigureAwait(false);

            return(result["retval"]);
        }
예제 #8
0
        public async Task <BsonValue> ExecuteAsync(IWriteBinding binding, TimeSpan timeout = default(TimeSpan), CancellationToken cancellationToken = default(CancellationToken))
        {
            Ensure.IsNotNull(binding, "binding");
            var command   = CreateCommand();
            var operation = new WriteCommandOperation(_databaseNamespace, command, _messageEncoderSettings);
            var result    = await operation.ExecuteAsync(binding, timeout, cancellationToken).ConfigureAwait(false);

            return(result["retval"]);
        }
예제 #9
0
        public async Task <BsonDocument> ExecuteAsync(IWriteBinding binding, TimeSpan timeout = default(TimeSpan), CancellationToken cancellationToken = default(CancellationToken))
        {
            Ensure.IsNotNull(binding, "binding");
            EnsureIsOutputToCollectionPipeline();

            var command   = CreateCommand();
            var operation = new WriteCommandOperation(DatabaseName, command);

            return(await operation.ExecuteAsync(binding, timeout, cancellationToken));
        }
예제 #10
0
        /// <inheritdoc/>
        public Task <TResult> ExecuteAsync(IWriteBinding binding, CancellationToken cancellationToken)
        {
            Ensure.IsNotNull(binding, "binding");
            var command   = CreateCommand();
            var operation = new WriteCommandOperation <TResult>(_collectionNamespace.DatabaseNamespace, command, _resultSerializer, _messageEncoderSettings)
            {
                CommandValidator = GetCommandValidator()
            };

            return(operation.ExecuteAsync(binding, cancellationToken));
        }
예제 #11
0
        /// <inheritdoc/>
        public Task <BsonDocument> ExecuteAsync(IWriteBinding binding, CancellationToken cancellationToken)
        {
            var command = CreateCommand();

            var operation = new WriteCommandOperation <BsonDocument>(
                _databaseNamespace,
                command,
                BsonDocumentSerializer.Instance,
                _messageEncoderSettings);

            return(operation.ExecuteAsync(binding, cancellationToken));
        }
        public async Task <BsonDocument> ExplainAsync(IWriteBinding binding, TimeSpan timeout = default(TimeSpan), CancellationToken cancellationToken = default(CancellationToken))
        {
            Ensure.IsNotNull(binding, "binding");
            EnsureIsOutputToCollectionPipeline();

            var command = CreateCommand();

            command["explain"] = true;
            var operation = new WriteCommandOperation(CollectionNamespace.DatabaseNamespace, command, MessageEncoderSettings);

            return(await operation.ExecuteAsync(binding, timeout, cancellationToken));
        }
        public Task <TResult> ExecuteAsync(IWriteBinding binding, TimeSpan timeout, System.Threading.CancellationToken cancellationToken)
        {
            Ensure.IsNotNull(binding, "binding");
            var command = CreateCommand();
            var nullableDeserializer = new PossiblyNullDeserializer(_resultSerializer);
            var serializer           = new ElementDeserializer <TResult>("value", nullableDeserializer);
            var operation            = new WriteCommandOperation <TResult>(_collectionNamespace.DatabaseNamespace, command, serializer, _messageEncoderSettings)
            {
                CommandValidator = GetCommandValidator()
            };

            return(operation.ExecuteAsync(binding, timeout, cancellationToken));
        }
예제 #14
0
        // methods
        public async Task <Cursor <BsonDocument> > ExecuteAsync(IWriteBinding binding, TimeSpan timeout = default(TimeSpan), CancellationToken cancellationToken = default(CancellationToken))
        {
            Ensure.IsNotNull(binding, "binding");

            var slidingTimeout = new SlidingTimeout(timeout);

            using (var connectionSource = await binding.GetWriteConnectionSourceAsync(slidingTimeout, cancellationToken))
            {
                var command   = CreateCommand();
                var operation = new WriteCommandOperation(CollectionNamespace.DatabaseNamespace, command, MessageEncoderSettings);
                var result    = await operation.ExecuteAsync(connectionSource, slidingTimeout, cancellationToken);

                return(CreateCursor(connectionSource, command, result, timeout, cancellationToken));
            }
        }
예제 #15
0
        /// <inheritdoc/>
        public async Task <BsonDocument> ExecuteAsync(IWriteBinding binding, CancellationToken cancellationToken)
        {
            Ensure.IsNotNull(binding, "binding");
            var command   = CreateCommand();
            var operation = new WriteCommandOperation <BsonDocument>(_collectionNamespace.DatabaseNamespace, command, BsonDocumentSerializer.Instance, _messageEncoderSettings);

            try
            {
                return(await operation.ExecuteAsync(binding, cancellationToken).ConfigureAwait(false));
            }
            catch (MongoCommandException ex)
            {
                if (ex.ErrorMessage != null && ex.ErrorMessage.Contains("ns not found"))
                {
                    return(ex.Result);
                }
                throw;
            }
        }
예제 #16
0
        public async Task <BsonDocument> ExecuteAsync(IWriteBinding binding, TimeSpan timeout = default(TimeSpan), CancellationToken cancellationToken = default(CancellationToken))
        {
            Ensure.IsNotNull(binding, "binding");
            var command   = CreateCommand();
            var operation = new WriteCommandOperation(_collectionNamespace.DatabaseNamespace, command, _messageEncoderSettings);

            try
            {
                return(await operation.ExecuteAsync(binding, timeout, cancellationToken));
            }
            catch (MongoCommandException ex)
            {
                var result = ex.Result;
                if ((string)result["errmsg"] == "ns not found")
                {
                    return(result);
                }
                throw;
            }
        }