コード例 #1
0
        private BulkWriteResult ExecuteInserts(MongoConnection connection, IEnumerable <InsertRequest> requests)
        {
            var operation = new BulkInsertOperation(new BulkInsertOperationArgs(
                                                        _assignId,
                                                        _checkElementNames,
                                                        _collectionName,
                                                        _databaseName,
                                                        _maxBatchCount,
                                                        _maxBatchLength,
                                                        _isOrdered,
                                                        _readerSettings,
                                                        requests,
                                                        _writeConcern,
                                                        _writerSettings));

            return(operation.Execute(connection));
        }
コード例 #2
0
        // public methods
        public IEnumerable <WriteConcernResult> Execute(MongoConnection connection)
        {
            var serverInstance = connection.ServerInstance;

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

            var operation = new BulkInsertOperation(_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(serverInstance, bulkWriteException);
            }
            else
            {
                if (_args.WriteConcern.Enabled)
                {
                    return(new[] { converter.ToWriteConcernResult(bulkWriteResult) });
                }
                else
                {
                    return(null);
                }
            }
        }
コード例 #3
0
        // public methods
        public IEnumerable<WriteConcernResult> Execute(MongoConnection connection)
        {
            var serverInstance = connection.ServerInstance;
            if (!serverInstance.Supports(FeatureId.WriteCommands))
            {
                throw new NotSupportedException("Write commands are not supported.");
            }

            var operation = new BulkInsertOperation(_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 new[] { converter.ToWriteConcernResult(bulkWriteResult) };
                }
                else
                {
                    return null;
                }
            }
        }
コード例 #4
0
 private BulkWriteResult ExecuteInserts(MongoConnection connection, IEnumerable<InsertRequest> requests)
 {
     var operation = new BulkInsertOperation(new BulkInsertOperationArgs(
         _assignId,
         _checkElementNames,
         _collectionName,
         _databaseName,
         _maxBatchCount,
         _maxBatchLength,
         _maxDocumentSize,
         _maxWireDocumentSize,
         _isOrdered,
         _readerSettings,
         requests,
         _writeConcern,
         _writerSettings));
     return operation.Execute(connection);
 }