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