@@ -135,7 +135,6 @@ You can print the results of the preceding example as follows:
135
135
136
136
var results = query.ToCursor();
137
137
138
-
139
138
Supported Aggregation Stages
140
139
----------------------------
141
140
@@ -519,7 +518,7 @@ The ``$group`` aggregation stage separates documents into groups according to
519
518
the criteria you specify.
520
519
521
520
Select the :guilabel:`Method Syntax` or :guilabel:`Query Syntax` tab to see how
522
- to generate an ``$group`` stage using LINQ:
521
+ to generate a ``$group`` stage using LINQ:
523
522
524
523
.. tabs::
525
524
@@ -570,7 +569,7 @@ The ``$sort`` aggregation stage returns the results of your query in the order
570
569
that you specify.
571
570
572
571
Select the :guilabel:`Method Syntax` or :guilabel:`Query Syntax` tab to see how
573
- to generate an ``$sort`` stage using LINQ:
572
+ to generate a ``$sort`` stage using LINQ:
574
573
575
574
.. tabs::
576
575
@@ -609,6 +608,35 @@ The following is a subset of the documents contained in the returned results:
609
608
{ "_id" : ObjectId(...), "name" : "Abaleh", "restaurant_id" : "50009096", "cuisine" : "Mediterranean", "address" : { ... }, "borough" : "Manhattan", "grades" : [...] }
610
609
...
611
610
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. You can
618
+ use To learn more about conversion behavior and permitted conversions,
619
+ see the :manual:`$convert reference
620
+ </reference/operator/aggregation/convert/>` 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 certain options to be set, 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 converted values in the output documents are stored under the original
638
+ field name.
639
+
612
640
$lookup
613
641
~~~~~~~
614
642
@@ -967,7 +995,6 @@ The result contains the following values:
967
995
0
968
996
1
969
997
970
-
971
998
Unsupported Aggregation Stages
972
999
------------------------------
973
1000
@@ -1005,6 +1032,9 @@ The following are some methods supported by the {+driver-long+} implementation o
1005
1032
* - ``LongCount``
1006
1033
- Returns an ``Int64`` that represents the number of documents that match the specified criteria
1007
1034
1035
+ * - ``Convert`` (only in ``Select`` projections)
1036
+ - Converts a value from one type to a different specified type
1037
+
1008
1038
* - ``DateFromString``
1009
1039
- Converts a ``string`` to a ``DateTime`` object
1010
1040
0 commit comments