@@ -23,7 +23,8 @@ Overview
23
23
On this page, you can learn how to use the {+driver-long+} to update array
24
24
fields in MongoDB documents. This page describes how to create ``UpdateDefinition<TDocument>``
25
25
objects that specify the update operations you want to perform on array fields.
26
- You can pass these objects to the update methods described on *this page.*
26
+ You can pass these objects to the update methods described on the
27
+ :ref:`<csharp-update-documents>` page.
27
28
28
29
The {+driver-short+} supports the array update operators and modifiers described in the
29
30
:manual:`{+mdb-server+} manual </reference/operator/update/#array>`.
@@ -325,17 +326,17 @@ To update all array elements that match your query filter, use the all positiona
325
326
The following code example queries the ``restaurants`` collection for a document
326
327
that contains a grade of 2. It then updates that grade to 22 in the matching documents.
327
328
328
-
329
- Updating Documents with LINQ3
330
- -----------------------------
329
+ LINQ3 Provider
330
+ ~~~~~~~~~~~~~~
331
331
332
332
LINQ syntax contains a positional operator (``$``) that you can use to update elements in an array field.
333
333
Previous versions of the {+driver-short+} supported both the LINQ2 and LINQ3 providers.
334
334
In LINQ2, you could use ``-1`` to indicate use of the positional operator.
335
335
336
336
For example, the ``Restaurant`` class contains an array field named ``Grades`` that
337
- contains multiple ``GradeEntry`` elements. The following code sample uses LINQ2 to update the
338
- ``Grade`` field of the first element in the ``Grades`` array:
337
+ contains multiple ``GradeEntry`` elements. If your application were using the LINQ2
338
+ provider, you could use the following code sample to update the
339
+ ``Grade`` field of the first element in this array:
339
340
340
341
.. code-block:: csharp
341
342
:linenos:
@@ -372,29 +373,3 @@ contains multiple ``GradeEntry`` elements. The following code sample uses LINQ2
372
373
Builders<Restaurant>.Update.Set(l => l.AnArrayMember.ElementAt(-1).Deleted, true));
373
374
374
375
This no longer works in LINQ3. Instead, you must use the following syntax:
375
-
376
- .. list-table::
377
- :widths: 30 70
378
- :header-rows: 1
379
-
380
- * - Elements to Match
381
- * - LINQ Syntax
382
- - {+driver-short+} Syntax
383
-
384
- * - First matching element
385
- * - ``array.$``
386
- - | Specifies the positional operator in LINQ3.
387
- See :manual:`the MongoDB server manual</reference/operator/update/positional>`
388
- for more information.
389
-
390
- * - All elements
391
- * - ``array.$[]``
392
- - | Specifies the positional operator in LINQ3.
393
- See :manual:`the MongoDB server manual</reference/operator/update/positional>`
394
- for more information.
395
-
396
- * - All matching elements
397
- * - ``array.$[<identifier>]``
398
- - | Specifies the positional operator in LINQ3.
399
- See :manual:`the MongoDB server manual</reference/operator/update/positional>`
400
- for more information.
0 commit comments