File tree Expand file tree Collapse file tree 4 files changed +48
-8
lines changed
includes/page-templates/update Expand file tree Collapse file tree 4 files changed +48
-8
lines changed Original file line number Diff line number Diff line change @@ -38,10 +38,12 @@ Code Placeholders
38
38
39
39
The code examples on this page use the following placeholders:
40
40
41
- - ``+srv``: Include this option in your connection string prefix only if you are connecting
42
- to a MongoDB Atlas cluster. To learn more about the ``+srv`` option, see
43
- :manual:`Connection String Formats </reference/connection-string/#connection-string-formats>`
44
- in the {+mdb-server+} manual.
41
+ - ``+srv``: Include this option in your connection string prefix only if you are
42
+ connecting to a MongoDB Atlas cluster. If you're using a
43
+ ``MongoClientSettings`` object, you can specify the ``srv`` format by setting
44
+ the ``Scheme`` property to ``ConnectionStringScheme.MongoDBPlusSrv``. To learn
45
+ more about the ``+srv`` option, see :manual:`Connection String Formats </reference/connection-string/#connection-string-formats>` in the
46
+ {+mdb-server+} manual.
45
47
- ``<hostname>``: The network address of your MongoDB deployment.
46
48
- ``<port>``: The port number of the MongoDB deployment. If you omit this parameter,
47
49
the driver uses the default port number (``27017``). You don't need a port number
@@ -119,6 +121,7 @@ see the corresponding syntax:
119
121
},
120
122
UseTls = true,
121
123
Server = new MongoServerAddress("<hostname>"[, "<port>"]),
124
+ Scheme = ConnectionStringScheme.MongoDBPlusSrv, // Needed when connecting to MongoDB Atlas
122
125
};
123
126
124
127
Troubleshooting
Original file line number Diff line number Diff line change @@ -183,6 +183,23 @@ The ``ReplaceOptions`` class contains the following properties:
183
183
184
184
**Data Type:** ``bool``
185
185
186
+ * - ``Sort``
187
+ - Determines which document the operation replaces if the query
188
+ selects multiple documents, because the replace operation replaces
189
+ the first document in the sort order specified. To set this
190
+ option, you must instantiate an ``ReplaceOptions<T>`` instance
191
+ that uses a generic type that models your data, as shown in the
192
+ following code:
193
+
194
+ .. code-block:: csharp
195
+
196
+ var options = new ReplaceOptions<Restaurant>
197
+ {
198
+ Sort = Builders<Restaurant>.Sort.Ascending(r => r.Name)
199
+ };
200
+
201
+ **Data Type:** ``SortDefinition<T>``
202
+
186
203
* - ``Let``
187
204
- Gets or sets the let document.
188
205
See :manual:`the {+mdb-server+} manual </reference/command/update/#std-label-update-let-syntax>`
@@ -268,4 +285,5 @@ see the following API documentation:
268
285
* `ReplaceOne() <{+new-api-root+}/MongoDB.Driver/MongoDB.Driver.IMongoCollection-1.ReplaceOne.html>`__
269
286
* `ReplaceOneAsync() <{+new-api-root+}/MongoDB.Driver/MongoDB.Driver.IMongoCollection-1.ReplaceOneAsync.html>`__
270
287
* `ReplaceOptions <{+new-api-root+}/MongoDB.Driver/MongoDB.Driver.ReplaceOptions.html>`__
271
- * `ReplaceOneResult <{+new-api-root+}/MongoDB.Driver/MongoDB.Driver.ReplaceOneResult.html>`__
288
+ * `ReplaceOneResult
289
+ <{+new-api-root+}/MongoDB.Driver/MongoDB.Driver.ReplaceOneResult.html>`__
Original file line number Diff line number Diff line change @@ -192,6 +192,23 @@ The ``UpdateOptions`` class contains the following properties:
192
192
193
193
**Data Type: ** ``bool ``
194
194
195
+ * - ``Sort ``
196
+ - Determines which document the operation updates if the query
197
+ selects multiple documents, because the update operation updates
198
+ the first document in the sort order specified. To set this
199
+ option, you must instantiate an ``UpdateOptions<T> `` instance
200
+ that uses a generic type that models your data, as shown in the
201
+ following code:
202
+
203
+ .. code-block :: csharp
204
+
205
+ var options = new UpdateOptions <Restaurant >
206
+ {
207
+ Sort = Builders <Restaurant >.Sort .Ascending (r => r .Name )
208
+ };
209
+
210
+ **Data Type: ** ``SortDefinition<T> ``
211
+
195
212
* - ``Let ``
196
213
- Gets or sets the let document.
197
214
See :manual: `the {+mdb-server+} manual </reference/command/update/#std-label-update-let-syntax> `
Original file line number Diff line number Diff line change @@ -179,9 +179,11 @@ The 3.1 driver release includes the following new features:
179
179
Vector Search, see :atlas:`Run Vector Search Queries </atlas-vector-search/vector-search-stage>`
180
180
in the Atlas Search documentation.
181
181
182
- - Adds support for the ``sort`` option to be passed to update commands. To learn more about
183
- using update commands with the {+driver-short+}, see :ref:`csharp-update-one` and
184
- :ref:`csharp-update-many`.
182
+ - Adds a sort option for update and replace operations. This change
183
+ allows you to set a sort order if multiple documents match your
184
+ filter when attempting to update or replace a single document. To
185
+ learn more, see the :ref:`csharp-update-one` and
186
+ :ref:`csharp-replace-operation` guides.
185
187
186
188
For more information about this release, see the :github:`v3.1 release notes
187
189
</mongodb/mongo-csharp-driver/releases/tag/v3.1.0>`.
You can’t perform that action at this time.
0 commit comments