private BulkWriteResult ExecuteUpdates(MongoConnection connection, IEnumerable <UpdateRequest> requests)
        {
            var operation = new BulkUpdateOperation(new BulkUpdateOperationArgs(
                                                        _checkElementNames,
                                                        _collectionName,
                                                        _databaseName,
                                                        _maxBatchCount,
                                                        _maxBatchLength,
                                                        _isOrdered,
                                                        _readerSettings,
                                                        requests,
                                                        _writeConcern,
                                                        _writerSettings));

            return(operation.Execute(connection));
        }
        // public methods
        public WriteConcernResult Execute(MongoConnection connection)
        {
            var serverInstance = connection.ServerInstance;

            if (!serverInstance.Supports(FeatureId.WriteCommands))
            {
                throw new NotSupportedException("Write commands are not supported.");
            }

            var operation = new BulkUpdateOperation(_args);

            BulkWriteResult    bulkWriteResult;
            BulkWriteException bulkWriteException = null;

            try
            {
                bulkWriteResult = operation.Execute(connection);
            }
            catch (BulkWriteException ex)
            {
                bulkWriteResult    = ex.Result;
                bulkWriteException = ex;
            }

            var converter = new BulkWriteResultConverter();

            if (bulkWriteException != null)
            {
                throw converter.ToWriteConcernException(bulkWriteException);
            }
            else
            {
                if (_args.WriteConcern.Enabled)
                {
                    return(converter.ToWriteConcernResult(bulkWriteResult));
                }
                else
                {
                    return(null);
                }
            }
        }
        // public methods
        public WriteConcernResult Execute(MongoConnection connection)
        {
            var serverInstance = connection.ServerInstance;
            if (!serverInstance.Supports(FeatureId.WriteCommands))
            {
                throw new NotSupportedException("Write commands are not supported.");
            }

            var operation = new BulkUpdateOperation(_args);

            BulkWriteResult bulkWriteResult;
            BulkWriteException bulkWriteException = null;
            try
            {
                bulkWriteResult = operation.Execute(connection);
            }
            catch (BulkWriteException ex)
            {
                bulkWriteResult = ex.Result;
                bulkWriteException = ex;
            }

            var converter = new BulkWriteResultConverter();
            if (bulkWriteException != null)
            {
                throw converter.ToWriteConcernException(bulkWriteException);
            }
            else
            {
                if (_args.WriteConcern.Enabled)
                {
                    return converter.ToWriteConcernResult(bulkWriteResult);
                }
                else
                {
                    return null;
                }
            }
        }
 private BulkWriteResult ExecuteUpdates(MongoConnection connection, IEnumerable<UpdateRequest> requests)
 {
     var operation = new BulkUpdateOperation(new BulkUpdateOperationArgs(
         _checkElementNames,
         _collectionName,
         _databaseName,
         _maxBatchCount,
         _maxBatchLength,
         _maxDocumentSize,
         _maxWireDocumentSize,
         _isOrdered,
         _readerSettings,
         requests,
         _writeConcern,
         _writerSettings));
     return operation.Execute(connection);
 }