Mongodb .net async await

半世苍凉 提交于 2019-12-07 12:32:30

问题


Does the mongodb .net driver offer support for async/await operations? I can't seem to find any info on this. I'm looking for something like EntityFramework has:

ToListAsync(), FindAsync(), CountAsync()

Is this supported?


回答1:


2.0 Driver is released. Check it out:

https://github.com/mongodb/mongo-csharp-driver

Nuget:

https://www.nuget.org/packages/MongoDB.Driver




回答2:


I've made some changes in the official driver to make it async as possible. Basically, I've changed the MongoConnection class to use the NetworkStream async methods (WriteAsync and ReadAsync) and propagated the changes all by the code.

Besides that, I've added the async LINQ methods like the EF6 (I actually took the extensions from the EF code and adapted to the mongo driver).

It's not production quality, but it's working.

https://github.com/andrebires/mongo-csharp-driver



来源:https://stackoverflow.com/questions/19740329/mongodb-net-async-await

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!