Ejemplo n.º 1
0
        // protected methods
        protected override BulkWriteBatchResult EmulateSingleRequest(MongoConnection connection, WriteRequest request, int originalIndex)
        {
            var serverInstance = connection.ServerInstance;
            var updateRequest  = (UpdateRequest)request;

            var updateRequests = new[] { updateRequest };
            var operationArgs  = new BulkUpdateOperationArgs(
                _args.CheckElementNames,
                _args.CollectionName,
                _args.DatabaseName,
                1,                               // maxBatchCount
                serverInstance.MaxMessageLength, // maxBatchLength
                serverInstance.MaxDocumentSize,
                serverInstance.MaxWireDocumentSize,
                true, // isOrdered
                _args.ReaderSettings,
                updateRequests,
                _args.WriteConcern,
                _args.WriterSettings);
            var operation = new UpdateOpcodeOperation(operationArgs);

            WriteConcernResult    writeConcernResult;
            WriteConcernException writeConcernException = null;

            try
            {
                writeConcernResult = operation.Execute(connection);
            }
            catch (WriteConcernException ex)
            {
                writeConcernResult    = ex.WriteConcernResult;
                writeConcernException = ex;
            }

            var indexMap = new IndexMap.RangeBased(0, originalIndex, 1);

            return(BulkWriteBatchResult.Create(
                       updateRequest,
                       writeConcernResult,
                       writeConcernException,
                       indexMap));
        }
        // protected methods
        protected override BulkWriteBatchResult EmulateSingleRequest(MongoConnection connection, WriteRequest request, int originalIndex)
        {
            var serverInstance = connection.ServerInstance;
            var updateRequest = (UpdateRequest)request;

            var updateRequests = new[] { updateRequest };
            var operationArgs = new BulkUpdateOperationArgs(
                _args.CheckElementNames,
                _args.CollectionName,
                _args.DatabaseName,
                1, // maxBatchCount
                serverInstance.MaxMessageLength, // maxBatchLength
                serverInstance.MaxDocumentSize,
                serverInstance.MaxWireDocumentSize,
                true, // isOrdered
                _args.ReaderSettings,
                updateRequests,
                _args.WriteConcern,
                _args.WriterSettings);
            var operation = new UpdateOpcodeOperation(operationArgs);

            WriteConcernResult writeConcernResult;
            WriteConcernException writeConcernException = null;
            try
            {
                writeConcernResult = operation.Execute(connection);
            }
            catch (WriteConcernException ex)
            {
                writeConcernResult = ex.WriteConcernResult;
                writeConcernException = ex;
            }

            var indexMap = new IndexMap.RangeBased(0, originalIndex, 1);
            return BulkWriteBatchResult.Create(
                updateRequest,
                writeConcernResult,
                writeConcernException,
                indexMap);
        }