@@ -20,11 +20,14 @@ Bulk Write Operations
2020Overview
2121--------
2222
23+ This guide shows you how to use the {+driver-short+} to perform **bulk write operations**
24+ that include multiple write operations in a single database call.
25+
2326Consider a scenario in which you want to insert a document into a collection,
2427update multiple other documents, then delete a document. If you use
25- individual methods, each operation requires its own database call. This guide
26- shows you how to use bulk write operations to perform multiple write operations
27- in a single database call.
28+ individual methods, each operation requires its own database call. If you use
29+ a bulk write operation, you can improve efficiency by performing multiple write
30+ operations in a single database call.
2831
2932Sample Data
3033~~~~~~~~~~~
@@ -51,11 +54,10 @@ The following sections show how to create and use instances of the preceding cla
5154
5255.. tip:: Bulk Write Operations with POCOs
5356
54- The examples in this guide use ``BsonDocument`` as the type for ``TDocument``.
55- You can also use a Plain Old CLR Object (POCO) as the type for ``TDocument``.
56-
57- To use a POCO, define a class that represents the documents in your collection.
58- The class must have properties that match the fields in your documents.
57+ The examples in this guide use the ``BsonDocument`` type for the ``TDocument`` type
58+ in all generic classes. You can also use a Plain Old CLR Object (POCO) for these
59+ classes. To do so, you must define a class that represents the documents in your
60+ collection. The class must have properties that match the fields in your documents.
5961 For more information, see :ref:`<csharp-poco>`.
6062
6163Insert Operations
@@ -164,11 +166,11 @@ parameters:
164166 | **Data Type:** `IEnumerable<ArrayFilterDefinition> <https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.ienumerable-1?view=net-8.0>`__
165167 | **Default:** ``null``
166168
167- The following example creates an instance of the ``BulkWriteUpdateOneModel<TDocument >``
168- class, and uses ``BsonDocument`` as the type for ``TDocument``. The
169- filter matches the first document in the ``sample_restaurants.restaurants`` collection
170- where the value of the ``name`` field is ``"Mongo's Deli"``. The update operation sets
171- the value of the ``cuisine`` field to ``"Sandwiches and Salads"``.
169+ In the following code example, the ``BulkWriteUpdateOneModel<BsonDocument >`` object
170+ represents an update operation on the ``sample_restaurants.restaurants`` collection.
171+ The operation matches the first document in the collection where the value of the ``name``
172+ field is ``"Mongo's Deli"``. It then updates the value of the ``cuisine`` field in the
173+ matched document to ``"Sandwiches and Salads"``.
172174
173175.. literalinclude:: /includes/fundamentals/code-examples/BulkWrite.cs
174176 :start-after: start-bulk-update-one
@@ -347,9 +349,10 @@ Run the Write Operations
347349------------------------
348350
349351After you define a ``BulkWriteModel`` instance for each operation that you want to perform,
350- pass an ``IReadOnlyList`` collection of these instances to the ``BulkWrite()`` or
351- ``BulkWriteAsync()`` method. By default, these methods run the operations in the order
352- they're defined in the collection.
352+ create an instance of a class that implements the ``IReadOnlyList`` interface. Add your
353+ ``BulkWriteModel`` objects to this ``IReadOnlyList``, then pass the ``IReadOnlyList``
354+ to the ``BulkWrite()`` or ``BulkWriteAsync()`` method. By default, these methods run
355+ the operations in the order they're defined in the collection.
353356
354357.. tip:: IReadOnlyList
355358
@@ -388,7 +391,7 @@ The preceding code examples produce the following output:
388391
389392 BulkWriteResult({'writeErrors': [], 'writeConcernErrors': [], 'nInserted': 2, 'nUpserted': 0, 'nMatched': 2, 'nModified': 2, 'nRemoved': 1, 'upserted': []}, acknowledged=True)
390393
391- .. tip:: Troubleshooting Bulk Write Operations
394+ .. tip::
392395
393396 If any of the write operations fail, the {+driver-short+} raises a
394397 ``BulkWriteException`` and does not perform any further operations. You can examine
0 commit comments