File tree Expand file tree Collapse file tree 3 files changed +27
-55
lines changed
fundamentals/crud/write-operations
code-examples/insert-many
fundamentals/code-examples/crud Expand file tree Collapse file tree 3 files changed +27
-55
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,13 @@ Insert Documents
1010 :depth: 2
1111 :class: singlecol
1212
13+ .. facet::
14+ :name: genre
15+ :values: reference
16+
17+ .. meta::
18+ :keywords: bulk, synchronous, asynchronous
19+
1320Overview
1421--------
1522
@@ -201,15 +208,15 @@ additional ``IsOrdered`` property:
201208Example
202209~~~~~~~
203210
204- The following code uses the ``InsertMany()`` method to insert four new
211+ The following code uses the ``InsertMany()`` method to insert five new
205212``Restaurant`` documents into a collection with
206213``BypassDocumentValidation`` set to ``true``:
207214
208- .. literalinclude:: /includes/fundamentals/ code-examples/crud/ insert.cs
215+ .. literalinclude:: /includes/code-examples/insert-many/InsertMany .cs
209216 :language: csharp
210217 :dedent:
211- :start-after: start-insert
212- :end-before: end-insert
218+ :start-after: start-insert-many-with-options
219+ :end-before: end-insert-many-with-options
213220
214221The ``InsertMany()`` method has no return value. You can verify that
215222your documents were successfully inserted by executing a ``Find()``
Original file line number Diff line number Diff line change @@ -54,6 +54,22 @@ private static void InsertManyRestaurants()
5454 // end-insert-many
5555 }
5656
57+ private static void InsertManyRestaurantsWithOptions ( )
58+ {
59+ Cleanup ( ) ;
60+
61+ // start-insert-many-with-options
62+ // Generates 5 new restaurants by using a helper method
63+ var restaurants = GenerateDocuments ( ) ;
64+
65+ // Creates an option object to bypass documentation validation on the documents
66+ var options = new InsertManyOptions ( ) { BypassDocumentValidation = true } ;
67+
68+ // Inserts the new documents into the restaurants collection with the specified options
69+ _restaurantsCollection . InsertMany ( restaurants , options ) ;
70+ // end-insert-many-with-options
71+ }
72+
5773 private static void Setup ( )
5874 {
5975 // Allows automapping of the camelCase database fields to models
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments