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
10
10
:depth: 2
11
11
:class: singlecol
12
12
13
+ .. facet::
14
+ :name: genre
15
+ :values: reference
16
+
17
+ .. meta::
18
+ :keywords: bulk, synchronous, asynchronous
19
+
13
20
Overview
14
21
--------
15
22
@@ -201,15 +208,15 @@ additional ``IsOrdered`` property:
201
208
Example
202
209
~~~~~~~
203
210
204
- The following code uses the ``InsertMany()`` method to insert four new
211
+ The following code uses the ``InsertMany()`` method to insert five new
205
212
``Restaurant`` documents into a collection with
206
213
``BypassDocumentValidation`` set to ``true``:
207
214
208
- .. literalinclude:: /includes/fundamentals/ code-examples/crud/ insert.cs
215
+ .. literalinclude:: /includes/code-examples/insert-many/InsertMany .cs
209
216
:language: csharp
210
217
: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
213
220
214
221
The ``InsertMany()`` method has no return value. You can verify that
215
222
your 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()
54
54
// end-insert-many
55
55
}
56
56
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
+
57
73
private static void Setup ( )
58
74
{
59
75
// 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