I'm attempting a "find all" query using the latest version of the C# MongoDB driver.
The code looks a bit like this
var xx = _context.NLMCDatabase.GetCollection<BsonDocument>("Requestables").Find<BsonDocument>(new BsonDocument());
var qq = xx.ToListAsync<BsonDocument>();
long yy = await xx.CountAsync();
The database connection is fine I use the same connection for inserting data. I have sent an empty query as
new BsonDocument()
The code executes but does not seem to return any results. When exploring with the debugger it reports
You are missing the await for the xx.ToListAsync<BsonDocument>();
which means the value of qq
will just be a task.
Try either:
var xx = _context.NLMCDatabase.GetCollection<BsonDocument>("Requestables").Find<BsonDocument>(new BsonDocument());
var qq = await xx.ToListAsync<BsonDocument>();
long yy = await xx.CountAsync();
or
var xx = _context.NLMCDatabase.GetCollection<BsonDocument>("Requestables").Find<BsonDocument>(new BsonDocument());
var qq = xx.ToListAsync<BsonDocument>();
long yy = await xx.CountAsync();
var listOfResults = await qq;
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.