Skip to content

Commit 5afe984

Browse files
committed
V3.0-backports (#378)
* DOCSP-35829-new-districtmany-method (#367) (cherry picked from commit 65e9142) * DOCSP-40654-sample-aggregation-operator (#360) * DOCSP-40654-sample-aggregation-operator * changed some syntax * update code example (cherry picked from commit 6d0a1e9) (cherry picked from commit 534d13b)
1 parent b87948f commit 5afe984

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

source/fundamentals/linq.txt

+26
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,32 @@ The result of the preceding example contains the following documents:
249249
{ "name" : "Crystal Room", "cuisine" : "Italian" }
250250
{ "name" : "Forlinis Restaurant", "cuisine" : "Italian" }
251251

252+
$sample
253+
~~~~~~~
254+
255+
The ``$sample`` aggregation stage returns a random sample of documents from a
256+
collection. The following example shows how to generate a ``$sample`` stage by using
257+
LINQ:
258+
259+
.. code-block:: csharp
260+
:emphasize-lines: 4
261+
262+
var query = queryableCollection
263+
.Aggregate()
264+
.Sample(4)
265+
.ToList();
266+
267+
The result of the preceding example contains the following documents:
268+
269+
.. code-block:: json
270+
271+
// Results Truncated
272+
273+
{ "name" : "Von Dolhens", "cuisine" : "Ice Cream, Gelato, Yogurt, Ices" }
274+
{ "name" : "New York Mercantile Exchange", "cuisine" : "American" }
275+
{ "name" : "Michaelangelo's Restaurant", "cuisine" : "Italian" }
276+
{ "name" : "Charlie Palmer Steak", "cuisine" : "American" }
277+
252278
$skip
253279
~~~~~
254280

0 commit comments

Comments
 (0)