Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions source/fundamentals/linq.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
~~~~~

Expand Down Expand Up @@ -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

Expand Down
Loading