File tree 3 files changed +41
-4
lines changed
fundamentals/crud/write-operations
includes/page-templates/update
3 files changed +41
-4
lines changed 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 @@ -70,9 +70,11 @@ The 3.1 driver release includes the following new features:
70
70
Vector Search, see :atlas:`Run Vector Search Queries </atlas-vector-search/vector-search-stage>`
71
71
in the Atlas Search documentation.
72
72
73
- - Adds support for the ``sort`` option to be passed to update commands. To learn more about
74
- using update commands with the {+driver-short+}, see :ref:`csharp-update-one` and
75
- :ref:`csharp-update-many`.
73
+ - Adds a sort option for update and replace operations. This change
74
+ allows you to set a sort order if multiple documents match your
75
+ filter when attempting to update or replace a single document. To
76
+ learn more, see the :ref:`csharp-update-one` and
77
+ :ref:`csharp-replace-operation` guides.
76
78
77
79
For more information about this release, see the :github:`v3.1 release notes
78
80
</mongodb/mongo-csharp-driver/releases/tag/v3.1.0>`.
You can’t perform that action at this time.
0 commit comments