Skip to content
Merged
Changes from 2 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
27 changes: 27 additions & 0 deletions source/fundamentals/linq.txt
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,33 @@ 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

{ "title" : "State of Play", "languages" : ["English"]}
{ "title" : "Bhopal: A Prayer for Rain", "languages" : ["English", "Hindi"] }
{ "title" : "Dead Presidents", "languages" : ["English"]}
{ "title" : "The Rains Came", "languages" : ["English"] }


$skip
~~~~~

Expand Down
Loading