हाँ, वहाँ है।
सबसे पहले FindAsync
का उपयोग न करें , उपयोग करें Find
बजाय। IFindFluent
. पर परिणाम SingleAsync
. का उपयोग करें एक्सटेंशन विधि और एक async विधि के अंदर दिए गए कार्य की प्रतीक्षा करें:
async Task MainAsync()
{
IMongoCollection<ApplicationUser> userCollection = ...;
var applicationUser = await userCollection.Find(_ => _.Id == inputId).SingleAsync();
}
नया ड्राइवर विशेष रूप से async-wait का उपयोग करता है। Task.Result
. का उपयोग करके इसे ब्लॉक न करें ।