protected override void When() { var subject = new BulkMixedWriteOperation(DatabaseName, CollectionName, _requests) { IsOrdered = false }; _result = ExecuteOperationAsync(subject).GetAwaiter().GetResult(); }
protected override void When() { var subject = new BulkMixedWriteOperation(DatabaseName, CollectionName, _requests) { MaxBatchCount = _maxBatchCount, }; _result = ExecuteOperationAsync(subject).GetAwaiter().GetResult(); }
public void OneTimeSetUp() { _connectionId = new ConnectionId(new ServerId(new ClusterId(1), new DnsEndPoint("localhost", 27017)), 2); var processedRequests = new[] { new InsertOneModel<BsonDocument>(new BsonDocument("b", 1)) }; var upserts = new BulkWriteUpsert[0]; _bulkWriteResult = new BulkWriteResult<BsonDocument>.Acknowledged(1, 1, 0, 0, 0, processedRequests, upserts); _writeConcernError = new WriteConcernError(11, "funny", new BsonDocument("c", 1)); _writeErrors = new[] { new BulkWriteError(10, ServerErrorCategory.Uncategorized, 1, "blah", new BsonDocument("a", 1)) }; _unprocessedRequests = new[] { new InsertOneModel<BsonDocument>(new BsonDocument("a", 1)) }; }
// constructors /// <summary> /// Initializes a new instance of the <see cref="BulkWriteException" /> class. /// </summary> /// <param name="result">The result.</param> /// <param name="writeErrors">The write errors.</param> /// <param name="unprocessedRequests">The unprocessed requests.</param> /// <param name="writeConcernError">The write concern error.</param> public BulkWriteException( BulkWriteResult result, IReadOnlyList<BulkWriteError> writeErrors, WriteConcernError writeConcernError, IReadOnlyList<WriteRequest> unprocessedRequests) : base("A bulk write operation resulted in one or more errors.") { _result = result; _writeErrors = writeErrors; _writeConcernError = writeConcernError; _unprocessedRequests = unprocessedRequests; }
public static BulkWriteBatchResult Create( BulkWriteResult result, BulkWriteException exception, IndexMap indexMap) { var matchedCount = 0L; var deletedCount = 0L; var insertedCount = 0L; long?modifiedCount = null; var upserts = __noUpserts; if (result.IsAcknowledged) { matchedCount = result.MatchedCount; deletedCount = result.DeletedCount; insertedCount = result.InsertedCount; modifiedCount = result.IsModifiedCountAvailable ? (long?)result.ModifiedCount : null; upserts = result.Upserts; } var unprocessedRequests = __noWriteRequests; var writeErrors = __noWriteErrors; WriteConcernError writeConcernError = null; if (exception != null) { unprocessedRequests = exception.UnprocessedRequests; writeErrors = exception.WriteErrors; writeConcernError = exception.WriteConcernError; } return(new BulkWriteBatchResult( result.RequestCount, result.ProcessedRequests, unprocessedRequests, matchedCount, deletedCount, insertedCount, modifiedCount, upserts, writeErrors, writeConcernError, indexMap)); }
public static BulkWriteBatchResult Create( BulkWriteResult result, BulkWriteException exception, IndexMap indexMap) { var matchedCount = 0L; var deletedCount = 0L; var insertedCount = 0L; long? modifiedCount = null; var upserts = __noUpserts; if (result.IsAcknowledged) { matchedCount = result.MatchedCount; deletedCount = result.DeletedCount; insertedCount = result.InsertedCount; modifiedCount = result.IsModifiedCountAvailable ? (long?)result.ModifiedCount : null; upserts = result.Upserts; } var unprocessedRequests = __noWriteRequests; var writeErrors = __noWriteErrors; WriteConcernError writeConcernError = null; if (exception != null) { unprocessedRequests = exception.UnprocessedRequests; writeErrors = exception.WriteErrors; writeConcernError = exception.WriteConcernError; } return new BulkWriteBatchResult( result.RequestCount, result.ProcessedRequests, unprocessedRequests, matchedCount, deletedCount, insertedCount, modifiedCount, upserts, writeErrors, writeConcernError, indexMap); }