A dynamic implementation of the CSharp Driver for Mongo.
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


DMongo - Dynamic wrapper for the CSharp Mongo Driver

This is an wrapper of the CSharpDriver for Mongo, using the Microsoft Dynamic syntax.

The idea behind this implementation is to create a DSL simple to use, more oriented to the Mongo Shell commands.

  • Using the CSharpDriver for Mongo

     var connectionString = "mongodb://localhost/?safe=true";
     var server = MongoServer.Create(connectionString);
     var database = server.GetDatabase("test");
     var collection = database.GetCollection<Entity>("mycollection");
     var entity = new Entity { Name = "Tom" };
     var id = entity.Id;
     var query = Query.EQ("_id", id);
     entity = collection.FindOne(query);
     Console.WriteLine("Result: {0}",entity.Name);

This example was taken from: CSharp Driver Quick Start There is a Test case based on the example above.

  • Using DMongo: A simple way to use the collections (like the mongo shell)

     var mongo = new Mongo("mongo://localhost/?safe=true");
     var db = mongo.GetDatabase("test");	
     var entity = db.mycollection.insert(new {name = "John" });
     var result = db.mycollection.findOne(new { name = "John" });
     Console.WriteLine("Result: {0}", result.name);


  1. Dynamic Collections (work in progress)
  2. Data Types (work in progress). Note: For now only annonymous types are accepted.
  3. DB Actions - Update, Insert, Delete (work in progress)
  4. DB Query - all Finders and Linq (not done)
  5. Same fuctionality from CSharp Driver (work in progress)
  6. Multithread - (not done)
  7. Reduced Maps - (not done)
  8. More and more...


  • This project is being develop on Mono for Mac using the CSharpDriver Libraries, NUnit and Mono implementation of the C# language.
  • I haven't tested it yet on a windows environment, but this inital commit should work.
  • I used the .NET Framework 4.0
  • All results are based on BsonDocument unless a entity is specified.


  • Cleanup the dynamic finds
  • Get more detail from the InvokeMemberBinder for a better implementation on the bypass functionality
  • More Test Cases


  • 08-16-2012: Added a Invoke for Generic Methods, so the CSharp Driver functionality is in place. Example:

     var result = db.test.FindOneAs<BsonDocument>(query);

My Blog