@@ -135,17 +135,17 @@ You can print the results of the preceding example as follows:
135135
136136 var results = query.ToCursor();
137137
138-
139138Supported Aggregation Stages
140139----------------------------
141140
142- 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/ >`.
143142The {+driver-short+} automatically translates each LINQ statement into the corresponding
144143aggregation pipeline stages. In this section you can learn which
145144aggregation pipeline stages are supported.
146145
147- To learn more about the aggregation pipeline stages, see the
148- :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.
149149
150150$project
151151~~~~~~~~
@@ -519,7 +519,7 @@ The ``$group`` aggregation stage separates documents into groups according to
519519the criteria you specify.
520520
521521Select the :guilabel:`Method Syntax` or :guilabel:`Query Syntax` tab to see how
522- to generate an ``$group`` stage using LINQ:
522+ to generate a ``$group`` stage using LINQ:
523523
524524.. tabs::
525525
@@ -570,7 +570,7 @@ The ``$sort`` aggregation stage returns the results of your query in the order
570570that you specify.
571571
572572Select the :guilabel:`Method Syntax` or :guilabel:`Query Syntax` tab to see how
573- to generate an ``$sort`` stage using LINQ:
573+ to generate a ``$sort`` stage using LINQ:
574574
575575.. tabs::
576576
@@ -793,6 +793,16 @@ in the Atlas manual. For more examples about running Atlas Vector Search queries
793793{+driver-short+}, see :atlas:`Run Vector Search Queries </atlas-vector-search/vector-search-stage/>`
794794in the Atlas manual and select :guilabel:`C#` from the language dropdown.
795795
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+
796806Bitwise Operators
797807~~~~~~~~~~~~~~~~~
798808
@@ -967,6 +977,42 @@ The result contains the following values:
967977 0
968978 1
969979
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.
9701016
9711017Unsupported Aggregation Stages
9721018------------------------------
@@ -984,7 +1030,8 @@ the :ref:`<csharp-builders-out>` section.
9841030Supported Methods
9851031-----------------
9861032
987- The following are some methods supported by the {+driver-long+} implementation of LINQ:
1033+ The following table describes some methods supported by the
1034+ {+driver-long+} implementation of LINQ:
9881035
9891036.. list-table::
9901037 :header-rows: 1
@@ -1005,6 +1052,9 @@ The following are some methods supported by the {+driver-long+} implementation o
10051052 * - ``LongCount``
10061053 - Returns an ``Int64`` that represents the number of documents that match the specified criteria
10071054
1055+ * - ``Convert``
1056+ - Converts a value from one type to a different specified type
1057+
10081058 * - ``DateFromString``
10091059 - Converts a ``string`` to a ``DateTime`` object
10101060
0 commit comments