MangoDBC#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"]);}
评论