Skip to content

V3.0-backports #378

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 16, 2024
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