mongo-csharp-driver

.NET Driver for MongoDB

Github stars Tracking Chart

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.

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.

Maintainers:

Contributors:

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).

Main metrics

Overview
Name With Ownermongodb/mongo-csharp-driver
Primary LanguageC#
Program languageJavaScript (Language Count: 7)
Platform
License:Apache License 2.0
所有者活动
Created At2010-06-02 18:22:21
Pushed At2025-04-22 22:11:38
Last Commit At
Release Count136
Last Release Namev3.3.0 (Posted on 2025-03-27 16:05:41)
First Release Namev0.5.0.3940 (Posted on 2010-11-04 10:12:32)
用户参与
Stargazers Count3.2k
Watchers Count236
Fork Count1.3k
Commits Count4.9k
Has Issues Enabled
Issues Count0
Issue Open Count0
Pull Requests Count1071
Pull Requests Open Count27
Pull Requests Close Count563
项目设置
Has Wiki Enabled
Is Archived
Is Fork
Is Locked
Is Mirror
Is Private