c# - Mongo `await FindAsync` doesn't compile. -
when try use await
keyword findall(filter)
method end un-compilable code. e.g.:
using (var cursor = await collection.findasync(filter)) { while (await cursor.movenextasync()) { var batch = cursor.current; foreach (var document in batch) { // process document count++; } } }
is giving:
the 'await' operator can used within async method. consider marking method 'async' modifier , changing return type 'task'.
if @ source, method indeed returning task
:
public static task<iasynccursor<tdocument>> findasync<tdocument>(...)
any idea what's going on here?
your function not marked async, not mongo 1 yours, 1 has code.
in order make async calls inside function must mark function async:
public async void yourfunction() { //here can use await }
else receive compile error.
Comments
Post a Comment