You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
rstam 007637d679 CSHARP-1576: Trying to get build.fsx working with NUnit3. 10 years ago
Docs CSHARP-1451: Fix broken links in Tailable Cursor documentation. 10 years ago
Release Notes Bumping version post release. 10 years ago
Tools/NuGet CSHARP-1139: Delete NUnit from the Tools directory. 10 years ago
build CSHARP-1576: Trying to get build.fsx working with NUnit3. 10 years ago
src CSHARP-1576: Trying to get build.fsx working with NUnit3. 10 years ago
.gitattributes The MongoDB.Bson.dll and MongoDB.Driver.dll are now strongly named. They are signed using a TemporaryKeyPair. Official binaries will be resigned using a different strong name key. 15 years ago
.gitignore CSHARP-1347: implemented command monitoring specification. 10 years ago
.travis.yml updated travis to not use brew 10 years ago
CONTRIBUTING.md CSHARP-578: added contributing doc. 13 years ago
License.rtf fixing up some extra 10gen related text. 12 years ago
License.txt fixing up some extra 10gen related text. 12 years ago
README.md CSHARP-1447: Fix copyrights and add new contributor to ReadMe. 10 years ago
appveyor.yml minor changes for 2.1.0-rc1 release. 10 years ago
build.cmd CSHARP-1139: Use NuGet to manage our dependency on NUnit. 10 years ago
build.sh CSHARP-1139: Use NuGet to manage our dependency on NUnit. 10 years ago
uuidhelpers.js Added uuidhelpers.js file with Javascript helper functions to work with the various encoding of UUIDs in the mongo shell. These will eventually be obsoleted when SERVER-3153 is implemented. 14 years ago

README.md

MongoDB C# Driver

You can get the latest stable release from the official Nuget.org feed or from our github releases page.

If you'd like to work with the bleeding edge, you can use our custom feed. Some packages on this feed are pre-release and, while they've passed all our tests, are not yet ready for production.

Build Status

.NET: Build status

Mono: Build Status

Getting Started

Untyped Documents

using MongoDB.Bson;
using MongoDB.Driver;
var client = new MongoClient("mongodb://localhost:27017");
var database = client.GetDatabase("foo");
var collection = client.GetCollection<BsonDocument>("bar");

await collection.InsertOneAsync(new BsonDocument("Name", "Jack"));

var list = await collection.Find(new BsonDocument("Name", "Jack"))
	.ToListAsync();

foreach(var document in list)
{
	Console.WriteLine(document["Name"]);
}

Typed Documents

using MongoDB.Bson;
using MongoDB.Driver;
public class Person
{
    public ObjectId Id { get; set; }
    public string Name { get; set; }
}
var client = new MongoClient("mongodb://localhost:27017");
var database = client.GetDatabase("foo");
var collection = database.GetCollection<Person>("bar");

await collection.InsertOneAsync(new Person { Name = "Jack" });

var list = await collection.Find(x => x.Name == "Jack")
	.ToListAsync();

foreach(var person in list)
{
	Console.WriteLine(person.Name);
}

Documentation

Questions/Bug Reports

If you’ve identified a security vulnerability in a driver or any other MongoDB project, please report it according to the instructions here.

Contributing

Please see our guidelines for contributing to the driver.

Maintainers:

Contributors (in alphabetical order):

If you have contributed and we have neglected to add you to this list please contact one of the maintainers to be added to the list (with apologies).