Skip to content

Commit dbaaf57

Browse files
committed
FP tech review 1
1 parent a5d5f83 commit dbaaf57

File tree

1 file changed

+51
-32
lines changed

1 file changed

+51
-32
lines changed

source/fundamentals/linq.txt

Lines changed: 51 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -138,13 +138,14 @@ You can print the results of the preceding example as follows:
138138
Supported Aggregation Stages
139139
----------------------------
140140

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/>`.
142142
The {+driver-short+} automatically translates each LINQ statement into the corresponding
143143
aggregation pipeline stages. In this section you can learn which
144144
aggregation pipeline stages are supported.
145145

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.
148149

149150
$project
150151
~~~~~~~~
@@ -608,35 +609,6 @@ The following is a subset of the documents contained in the returned results:
608609
{ "_id" : ObjectId(...), "name" : "Abaleh", "restaurant_id" : "50009096", "cuisine" : "Mediterranean", "address" : { ... }, "borough" : "Manhattan", "grades" : [...] }
609610
...
610611

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-
640612
$lookup
641613
~~~~~~~
642614

@@ -821,6 +793,16 @@ in the Atlas manual. For more examples about running Atlas Vector Search queries
821793
{+driver-short+}, see :atlas:`Run Vector Search Queries </atlas-vector-search/vector-search-stage/>`
822794
in the Atlas manual and select :guilabel:`C#` from the language dropdown.
823795

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+
824806
Bitwise Operators
825807
~~~~~~~~~~~~~~~~~
826808

@@ -995,6 +977,43 @@ The result contains the following values:
995977
0
996978
1
997979

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+
9981017
Unsupported Aggregation Stages
9991018
------------------------------
10001019

0 commit comments

Comments
 (0)