mongo-csharp-driver

.NET Driver for MongoDB

Github星跟踪图

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

主要指标

概览
名称与所有者mongodb/mongo-csharp-driver
主编程语言C#
编程语言JavaScript (语言数: 7)
平台
许可证Apache License 2.0
所有者活动
创建于2010-06-02 18:22:21
推送于2025-06-25 16:39:51
最后一次提交
发布数137
最新版本名称v3.4.0 (发布于 2025-05-01 11:20:33)
第一版名称v0.5.0.3940 (发布于 2010-11-04 10:12:32)
用户参与
星数3.2k
关注者数234
派生数1.3k
提交数4.9k
已启用问题?
问题数0
打开的问题数0
拉请求数1110
打开的拉请求数19
关闭的拉请求数572
项目设置
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?