File tree Expand file tree Collapse file tree 1 file changed +17
-10
lines changed
source/fundamentals/crud/read-operations Expand file tree Collapse file tree 1 file changed +17
-10
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,13 @@ Retrieve Data
10
10
:depth: 2
11
11
:class: singlecol
12
12
13
+ .. facet::
14
+ :name: genre
15
+ :values: reference
16
+
17
+ .. meta::
18
+ :keywords: code examples, read, search, cursor
19
+
13
20
Overview
14
21
--------
15
22
@@ -216,12 +223,12 @@ To see a full list of available options, see
216
223
Example
217
224
~~~~~~~
218
225
219
- The following example performs these actions:
226
+ This example performs the following actions:
220
227
221
228
- Finds all documents with "Pizza" in the ``cuisine`` field
222
229
- Sets the ``BatchSize`` to ``3``
223
230
- Stores the results in a cursor
224
- - Prints the number of documents currently held in the cursor
231
+ - Prints the documents referenced by the cursor
225
232
226
233
.. io-code-block::
227
234
:copyable: true
@@ -230,21 +237,21 @@ The following example performs these actions:
230
237
:language: csharp
231
238
232
239
var filter = Builders<Restaurant>.Filter.Eq("cuisine", "Pizza");
233
-
234
- var findOptions = new FindOptions
235
- {
236
- BatchSize = 3
237
- };
240
+ var findOptions = new FindOptions { BatchSize = 3 };
238
241
239
242
using (var cursor = _restaurantsCollection.Find(filter, findOptions).ToCursor())
240
243
{
241
- cursor.MoveNext();
242
- Console.WriteLine($"Number of documents in cursor: {cursor.Current.Count()}");
244
+ foreach (var r in cursor.ToEnumerable())
245
+ {
246
+ WriteLine(r.Name);
247
+ }
243
248
}
244
249
245
250
.. output::
246
251
247
- Number of documents in cursor: 3
252
+ Pizza Town
253
+ Victoria Pizza
254
+ ...
248
255
249
256
.. tip:: Clean Up
250
257
You can’t perform that action at this time.
0 commit comments