Skip to content

Commit f7174cf

Browse files
committed
Fixes
1 parent c0b6900 commit f7174cf

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

source/crud/query/cursors.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,9 @@ A cursor is a mechanism that returns the results of a read operation in iterable
2727
batches. Because a cursor holds only a subset of documents at any given time,
2828
cursors 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

3334
Sample Data
3435
~~~~~~~~~~~

source/includes/fundamentals/code-examples/Cursor.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System.Threading.Tasks;
12
using MongoDB.Bson;
23
using MongoDB.Bson.Serialization.Attributes;
34
using 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
{

0 commit comments

Comments
 (0)