@@ -138,13 +138,14 @@ You can print the results of the preceding example as follows:
138
138
Supported Aggregation Stages
139
139
----------------------------
140
140
141
- You can use LINQ to create an :ref :`aggregation pipeline <aggregation-pipeline-intro >`.
141
+ You can use LINQ to create an :manual :`aggregation pipeline </core/ aggregation-pipeline/ >`.
142
142
The {+driver-short+} automatically translates each LINQ statement into the corresponding
143
143
aggregation pipeline stages. In this section you can learn which
144
144
aggregation pipeline stages are supported.
145
145
146
- To learn more about the aggregation pipeline stages, see the
147
- :ref:`aggregation-pipeline-operator-reference` page in the server manual.
146
+ To learn more about the aggregation pipeline stages, see
147
+ :manual:`Aggregation Stages </reference/operator/aggregation-pipeline/>`
148
+ in the {+mdb-server+} manual.
148
149
149
150
$project
150
151
~~~~~~~~
@@ -608,35 +609,6 @@ The following is a subset of the documents contained in the returned results:
608
609
{ "_id" : ObjectId(...), "name" : "Abaleh", "restaurant_id" : "50009096", "cuisine" : "Mediterranean", "address" : { ... }, "borough" : "Manhattan", "grades" : [...] }
609
610
...
610
611
611
- .. _csharp-linq-convert:
612
-
613
- $convert
614
- ~~~~~~~~
615
-
616
- You can use the ``Mql.Convert()`` method in a ``Select()`` projection to
617
- convert a value from one type to a different specified type. To learn
618
- more about conversion behavior and permitted conversions, see the
619
- :manual:`$convert reference </reference/operator/aggregation/convert/>`
620
- in the {+mdb-server+} manual.
621
-
622
- The ``Convert()`` method takes the following parameters:
623
-
624
- - Value to convert.
625
- - ``ConvertOptions<Tto>`` instance that specifies the type to convert to
626
- and options. Some conversions require you to specify certain options, but
627
- you can also set options to handle errors or null values.
628
-
629
- The following code converts the ``RestaurantId`` string values to
630
- ``int`` values in a projection by using LINQ:
631
-
632
- .. code-block:: csharp
633
-
634
- var query = queryableCollection
635
- .Select(r => Mql.Convert(r.RestaurantId, new ConvertOptions<int>()));
636
-
637
- The driver stores the converted values under the original field name in
638
- the output documents.
639
-
640
612
$lookup
641
613
~~~~~~~
642
614
@@ -821,6 +793,16 @@ in the Atlas manual. For more examples about running Atlas Vector Search queries
821
793
{+driver-short+}, see :atlas:`Run Vector Search Queries </atlas-vector-search/vector-search-stage/>`
822
794
in the Atlas manual and select :guilabel:`C#` from the language dropdown.
823
795
796
+ Aggregation Operators
797
+ ---------------------
798
+
799
+ You can use :manual:`aggregation pipeline operators
800
+ </reference/operator/aggregation/>` in your aggregation stages to modify
801
+ documents and perform calculations.
802
+
803
+ The following sections describe aggregation operators that you can
804
+ implement by using LINQ methods.
805
+
824
806
Bitwise Operators
825
807
~~~~~~~~~~~~~~~~~
826
808
@@ -995,6 +977,43 @@ The result contains the following values:
995
977
0
996
978
1
997
979
980
+ .. _csharp-linq-convert:
981
+
982
+ $convert
983
+ ~~~~~~~~
984
+
985
+ The ``$convert`` operator converts a value to a specified type. You can
986
+ use this operator to perform type conversions in stages such as
987
+ ``$project``, ``$addFields``, and ``$set``.
988
+
989
+ In the driver, you can use the ``Mql.Convert()`` method to
990
+ convert a value from one type to a different specified type. To learn
991
+ more about conversion behavior and permitted conversions, see the
992
+ :manual:`$convert reference </reference/operator/aggregation/convert/>`
993
+ in the {+mdb-server+} manual.
994
+
995
+ The ``Convert()`` method takes the following parameters:
996
+
997
+ - Value to convert.
998
+ - ``ConvertOptions`` instance that specifies the type to convert to
999
+ and options. Some conversions require you to specify certain options, but
1000
+ you can also set options to handle errors or null values.
1001
+
1002
+ The following code performs the following actions by using LINQ methods:
1003
+
1004
+ - Converts the ``RestaurantId`` string values to ``int`` values in a
1005
+ ``Select()`` projection
1006
+ - Sets the returned value to ``-1`` if an error occurs during conversion
1007
+ - Sets the returned value to ``0`` if the input value is ``null`` or missing
1008
+
1009
+ .. code-block:: csharp
1010
+
1011
+ var query = queryableCollection
1012
+ .Select(r => Mql.Convert(r.RestaurantId, new ConvertOptions<int>( OnError = -1, OnNull = 0 )));
1013
+
1014
+ The driver stores the converted values under the original field name in
1015
+ the output documents.
1016
+
998
1017
Unsupported Aggregation Stages
999
1018
------------------------------
1000
1019
0 commit comments