Skip to content

Commit 0849bd5

Browse files
authored
Remove duplicate insertMany() examples (#153)
* succeed Insert.cs with InsertMany.cs
1 parent 1f23b30 commit 0849bd5

File tree

3 files changed

+27
-55
lines changed

3 files changed

+27
-55
lines changed

source/fundamentals/crud/write-operations/insert.txt

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff 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+
1320
Overview
1421
--------
1522

@@ -201,15 +208,15 @@ additional ``IsOrdered`` property:
201208
Example
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

214221
The ``InsertMany()`` method has no return value. You can verify that
215222
your documents were successfully inserted by executing a ``Find()``

source/includes/code-examples/insert-many/InsertMany.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff 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

source/includes/fundamentals/code-examples/crud/insert.cs

Lines changed: 0 additions & 51 deletions
This file was deleted.

0 commit comments

Comments
 (0)