Mongodb C # Async Library

I use ASP.net Web API and MongoDB to create a simple service.

I use the official Mongodb C # library.

How can I do this async? I think the official Mongodb C # library does not support Async.

Is it possible to just create an Async controller, but not a select statement?

Controller:

public IQueryable<Test> GetAllPlaces() { return _test.GetAllPlaces().AsQueryable(); } 

Choose from mongodb database:

 public IEnumerable<Test> GetAllPlaces() { return _test.FindAll(); } 

Thanks.

+4
source share
3 answers

While you can do this asynchronously, this will not give you any real performance gains, since the core library is not Async. There is much more and is described here here . The general answer is no.

+3
source

A bit old question, but the full MongoDB asynchronous driver for C # will appear in November 2013:

https://jira.mongodb.org/browse/CSHARP-138

edit - As Eugene said, the driver is still under development. There are several pilot projects on Github while we wait for the official one.

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

Update 02-Apr-2015:

2.0 is missing !: Nuget Link But keep in mind that async GridFS is not yet supported, you will need to continue to use the outdated package to work with it until they release it, probably in version 2.1

(thanks paqogomez for the heads)

+4
source

Switching to the old thread is here, but you can let FYI in C # run with SafeMode.False as a parameter (I believe that it is actually disabled by default), which will execute them in fire mode and forget it.

My code for most of my things is as follows:

 IMongoQuery query = Query.EQ("_id", Path); IMongoUpdate update = Update.Set("Key", "value"); SafeModeResult oCmd = mCollection.Update(query, update, SafeMode.True); 

Because I need a safe mode. But if you set it to false or leave this parameter, you will get fire and forget the functionality.

+1
source

All Articles