File tree Expand file tree Collapse file tree 2 files changed +6
-4
lines changed
includes/fundamentals/code-examples Expand file tree Collapse file tree 2 files changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -27,8 +27,9 @@ A cursor is a mechanism that returns the results of a read operation in iterable
2727batches. Because a cursor holds only a subset of documents at any given time,
2828cursors reduce both memory consumption and network bandwidth usage.
2929
30- You can retrieve a cursor by using the ``FindSync()`` and ``FindAsync()`` methods,
31- or by using the ``Find.ToCursor()`` and ``Find.ToCursorAsync()`` methods.
30+ You can retrieve a cursor by using the ``FindSync()`` and ``FindAsync()`` methods. You can
31+ also convert the results of the ``Find()`` method to a cursor by chaining the ``ToCursor()``
32+ or ``ToCursorAsync()`` method.
3233
3334Sample Data
3435~~~~~~~~~~~
Original file line number Diff line number Diff line change 1+ using System . Threading . Tasks ;
12using MongoDB . Bson ;
23using MongoDB . Bson . Serialization . Attributes ;
34using MongoDB . Driver ;
@@ -7,7 +8,7 @@ public class Cursor
78 // Replace with your connection string
89 private const string MongoConnectionString = "<connection URI>" ;
910
10- public static void Main ( string [ ] args )
11+ public static async Task Main ( string [ ] args )
1112 {
1213 var mongoClient = new MongoClient ( MongoConnectionString ) ;
1314 var database = mongoClient . GetDatabase ( "sample_restaurants" ) ;
@@ -127,7 +128,7 @@ public static void Main(string[] args)
127128
128129 using ( var cursor = await collection . FindAsync ( filter , options ) )
129130 {
130- while ( cursor . MoveNext ( ) )
131+ while ( await cursor . MoveNext ( ) )
131132 {
132133 foreach ( var restaurant in cursor . Current )
133134 {
You can’t perform that action at this time.
0 commit comments