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
26 changes: 26 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
Loading