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);
}
}
}
}
执行它时,我收到以下错误:
await和cursor在当前上下文中不存在。