private void button10_Click(object sender, EventArgs e)
{
var db = mongo.GetDatabase("milk123");
mongo.Connect();
var collection = db.GetCollection<BsonDocument>("stock123");
using (var cursor = await col.Find(new BsonDocument()).ToCursorAsync())
{
while (await cursor.MoveNextAsync())
{
foreach (var doc in cursor.Current)
{
Console.WriteLine(doc);
}
}
}
}
On executing it i am getting the following error:
await and cursor does not exist in current context.
await
keyword can be used inside async
methods only
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.