MangoDB C# Driver 是一个支持 10gen,用于 MongoDB 的 C#/.NET 驱动。
示例代码:
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"]); }