File tree Expand file tree Collapse file tree 3 files changed +38
-5
lines changed
fundamentals/crud/write-operations
includes/page-templates/update Expand file tree Collapse file tree 3 files changed +38
-5
lines changed Original file line number Diff line number Diff line change @@ -183,6 +183,21 @@ The ``ReplaceOptions`` class contains the following properties:
183183
184184 **Data Type:** ``bool``
185185
186+ * - ``Sort``
187+ - Specifies a sort order to apply to documents before the server
188+ performs the replace operation. To set this option, you must
189+ instantiate a ``ReplaceOptions<T>`` instance that uses a generic
190+ type that models your data, as shown in the following code:
191+
192+ .. code-block:: csharp
193+
194+ var options = new ReplaceOptions<Restaurant>
195+ {
196+ Sort = Builders<Restaurant>.Sort.Ascending(r => r.Name)
197+ };
198+
199+ **Data Type:** ``SortDefinition<T>``
200+
186201 * - ``Let``
187202 - Gets or sets the let document.
188203 See :manual:`the {+mdb-server+} manual </reference/command/update/#std-label-update-let-syntax>`
@@ -268,4 +283,5 @@ see the following API documentation:
268283* `ReplaceOne() <{+new-api-root+}/MongoDB.Driver/MongoDB.Driver.IMongoCollection-1.ReplaceOne.html>`__
269284* `ReplaceOneAsync() <{+new-api-root+}/MongoDB.Driver/MongoDB.Driver.IMongoCollection-1.ReplaceOneAsync.html>`__
270285* `ReplaceOptions <{+new-api-root+}/MongoDB.Driver/MongoDB.Driver.ReplaceOptions.html>`__
271- * `ReplaceOneResult <{+new-api-root+}/MongoDB.Driver/MongoDB.Driver.ReplaceOneResult.html>`__
286+ * `ReplaceOneResult
287+ <{+new-api-root+}/MongoDB.Driver/MongoDB.Driver.ReplaceOneResult.html>`__
Original file line number Diff line number Diff line change @@ -192,6 +192,21 @@ The ``UpdateOptions`` class contains the following properties:
192192
193193 **Data Type: ** ``bool ``
194194
195+ * - ``Sort ``
196+ - Specifies a sort order to apply to documents before the server
197+ performs the update operation. To set this option, you must
198+ instantiate an ``UpdateOptions<T> `` instance that uses a generic
199+ type that models your data, as shown in the following code:
200+
201+ .. code-block :: csharp
202+
203+ var options = new UpdateOptions <Restaurant >
204+ {
205+ Sort = Builders <Restaurant >.Sort .Ascending (r => r .Name )
206+ };
207+
208+ **Data Type: ** ``SortDefinition<T> ``
209+
195210 * - ``Let ``
196211 - Gets or sets the let document.
197212 See :manual: `the {+mdb-server+} manual </reference/command/update/#std-label-update-let-syntax> `
@@ -261,4 +276,4 @@ guide, see the following API documentation:
261276- `UpdateOptions <{+new-api-root+}/MongoDB.Driver/MongoDB.Driver.UpdateOptions.html >`__
262277- `UpdateResult <{+new-api-root+}/MongoDB.Driver/MongoDB.Driver.UpdateResult.html >`__
263278
264- |instruqt-lab-component |
279+ |instruqt-lab-component |
Original file line number Diff line number Diff line change @@ -149,9 +149,11 @@ The 3.1 driver release includes the following new features:
149149 Vector Search, see :atlas:`Run Vector Search Queries </atlas-vector-search/vector-search-stage>`
150150 in the Atlas Search documentation.
151151
152- - Adds support for the ``sort`` option to be passed to update commands. To learn more about
153- using update commands with the {+driver-short+}, see :ref:`csharp-update-one` and
154- :ref:`csharp-update-many`.
152+ - Adds a sort option for update and replace operations. This change
153+ allows you to set a sort order if multiple documents match your
154+ filter when attempting to update or replace a single document. To
155+ learn more, see the :ref:`csharp-update-one` and
156+ :ref:`csharp-replace-operation` guides.
155157
156158For more information about this release, see the :github:`v3.1 release notes
157159</mongodb/mongo-csharp-driver/releases/tag/v3.1.0>`.
You can’t perform that action at this time.
0 commit comments