File tree Expand file tree Collapse file tree 3 files changed +41
-4
lines changed
fundamentals/crud/write-operations
includes/page-templates/update Expand file tree Collapse file tree 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:
183183
184184 **Data Type:** ``bool``
185185
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+
186203 * - ``Let``
187204 - Gets or sets the let document.
188205 See :manual:`the {+mdb-server+} manual </reference/command/update/#std-label-update-let-syntax>`
@@ -268,4 +285,5 @@ see the following API documentation:
268285* `ReplaceOne() <{+new-api-root+}/MongoDB.Driver/MongoDB.Driver.IMongoCollection-1.ReplaceOne.html>`__
269286* `ReplaceOneAsync() <{+new-api-root+}/MongoDB.Driver/MongoDB.Driver.IMongoCollection-1.ReplaceOneAsync.html>`__
270287* `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:
192192
193193 **Data Type: ** ``bool ``
194194
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+
195212 * - ``Let ``
196213 - Gets or sets the let document.
197214 See :manual: `the {+mdb-server+} manual </reference/command/update/#std-label-update-let-syntax> `
Original file line number Diff line number Diff line change @@ -167,9 +167,11 @@ The 3.1 driver release includes the following new features:
167167 Vector Search, see :atlas:`Run Vector Search Queries </atlas-vector-search/vector-search-stage>`
168168 in the Atlas Search documentation.
169169
170- - Adds support for the ``sort`` option to be passed to update commands. To learn more about
171- using update commands with the {+driver-short+}, see :ref:`csharp-update-one` and
172- :ref:`csharp-update-many`.
170+ - Adds a sort option for update and replace operations. This change
171+ allows you to set a sort order if multiple documents match your
172+ filter when attempting to update or replace a single document. To
173+ learn more, see the :ref:`csharp-update-one` and
174+ :ref:`csharp-replace-operation` guides.
173175
174176For more information about this release, see the :github:`v3.1 release notes
175177</mongodb/mongo-csharp-driver/releases/tag/v3.1.0>`.
You can’t perform that action at this time.
0 commit comments