Skip to content

Commit 534d13b

Browse files
authored
V3.0-backports (#378)
* DOCSP-35829-new-districtmany-method (#367) (cherry picked from commit 65e9142) * DOCSP-40654-sample-aggregation-operator (#360) * DOCSP-40654-sample-aggregation-operator * changed some syntax * update code example (cherry picked from commit 6d0a1e9)
1 parent ded1e20 commit 534d13b

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

source/fundamentals/linq.txt

+32
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,32 @@ The result of the preceding example contains the following documents:
249249
{ "name" : "Crystal Room", "cuisine" : "Italian" }
250250
{ "name" : "Forlinis Restaurant", "cuisine" : "Italian" }
251251

252+
$sample
253+
~~~~~~~
254+
255+
The ``$sample`` aggregation stage returns a random sample of documents from a
256+
collection. The following example shows how to generate a ``$sample`` stage by using
257+
LINQ:
258+
259+
.. code-block:: csharp
260+
:emphasize-lines: 4
261+
262+
var query = queryableCollection
263+
.Aggregate()
264+
.Sample(4)
265+
.ToList();
266+
267+
The result of the preceding example contains the following documents:
268+
269+
.. code-block:: json
270+
271+
// Results Truncated
272+
273+
{ "name" : "Von Dolhens", "cuisine" : "Ice Cream, Gelato, Yogurt, Ices" }
274+
{ "name" : "New York Mercantile Exchange", "cuisine" : "American" }
275+
{ "name" : "Michaelangelo's Restaurant", "cuisine" : "Italian" }
276+
{ "name" : "Charlie Palmer Steak", "cuisine" : "American" }
277+
252278
$skip
253279
~~~~~
254280

@@ -809,6 +835,12 @@ The following are some methods supported by the {+driver-long+} implementation o
809835
* - ``Exists``
810836
- Tests whether a field exists
811837

838+
* - ``DistinctMany``
839+
- Returns distinct documents from an array that match the specified criteria
840+
841+
* - ``Exists``
842+
- Tests whether a field exists
843+
812844
* - ``First``
813845
- Returns the first matching document, and throws an exception if none are found
814846

0 commit comments

Comments
 (0)