diff --git a/source/fundamentals/linq.txt b/source/fundamentals/linq.txt index 491c98e7..8e915f81 100644 --- a/source/fundamentals/linq.txt +++ b/source/fundamentals/linq.txt @@ -249,6 +249,32 @@ The result of the preceding example contains the following documents: { "name" : "Crystal Room", "cuisine" : "Italian" } { "name" : "Forlinis Restaurant", "cuisine" : "Italian" } +$sample +~~~~~~~ + +The ``$sample`` aggregation stage returns a random sample of documents from a +collection. The following example shows how to generate a ``$sample`` stage by using +LINQ: + +.. code-block:: csharp + :emphasize-lines: 4 + + var query = queryableCollection + .Aggregate() + .Sample(4) + .ToList(); + +The result of the preceding example contains the following documents: + +.. code-block:: json + + // Results Truncated + + { "name" : "Von Dolhens", "cuisine" : "Ice Cream, Gelato, Yogurt, Ices" } + { "name" : "New York Mercantile Exchange", "cuisine" : "American" } + { "name" : "Michaelangelo's Restaurant", "cuisine" : "Italian" } + { "name" : "Charlie Palmer Steak", "cuisine" : "American" } + $skip ~~~~~ @@ -804,6 +830,12 @@ implementation of LINQ: * - ``Distinct`` - Returns distinct documents that match the specified criteria + * - ``DistinctMany`` + - Returns distinct documents from an array that match the specified criteria + + * - ``Exists`` + - Tests whether a field exists + * - ``First`` - Returns the first matching document, and throws an exception if none are found