From 827c48066ef2d3bd1621ee40d9782fa0529f761f Mon Sep 17 00:00:00 2001 From: gmiller-mdb <135852653+gmiller-mdb@users.noreply.github.com> Date: Thu, 12 Dec 2024 10:24:38 -0500 Subject: [PATCH 1/2] DOCSP-35829-new-districtmany-method (#367) (cherry picked from commit 65e9142882e5dee782c495d98980c2e55d1a7ea9) --- source/fundamentals/linq.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/source/fundamentals/linq.txt b/source/fundamentals/linq.txt index 491c98e7..0027b034 100644 --- a/source/fundamentals/linq.txt +++ b/source/fundamentals/linq.txt @@ -804,6 +804,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 From 601aaaa32ef8083cd68b50fef566184ef2e62a3d Mon Sep 17 00:00:00 2001 From: gmiller-mdb <135852653+gmiller-mdb@users.noreply.github.com> Date: Mon, 16 Dec 2024 13:06:31 -0500 Subject: [PATCH 2/2] DOCSP-40654-sample-aggregation-operator (#360) * DOCSP-40654-sample-aggregation-operator * changed some syntax * update code example (cherry picked from commit 6d0a1e921f076595e16f662091f3f1a0197184f2) --- source/fundamentals/linq.txt | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/source/fundamentals/linq.txt b/source/fundamentals/linq.txt index 0027b034..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 ~~~~~