C# Apache-2.0

mongo-csharp-driver

The Official C# .NET Driver for MongoDB

M

mongodb

Dernière activité 22 sept. 2026
mongodb/mongo-csharp-driver

3,2 k

étoiles

1,3 k

forks

16

issues ouvertes

csharpcsharp-librarydotnet-frameworkmongodbnosql

Ce README est souvent en anglais.

MongoDB C# Driver

MongoDB.Driver Documentation Documentation License

The official MongoDB .NET/C# driver.

The MongoDB .NET/C# driver follows semantic versioning since v3.0.0 of its releases.

Getting Started

Untyped Documents

using MongoDB.Bson;
using MongoDB.Driver;
var client = new MongoClient("mongodb://localhost:27017");
var database = client.GetDatabase("foo");
var collection = database.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.

Thank you to everyone who has contributed to this project.

Projets similaires

The Official Golang driver for MongoDB

Godatabasedrivergo
Mmongodb
8,5 k étoiles939

The official MongoDB Node.js driver

TypeScriptdatabasemongodbnode-js
Mmongodb
10,2 k étoiles1,8 k

The Official MongoDB driver for C language

Ccmongodbmongodb-driver
Mmongodb
882 étoiles474