net官方驱动操作MongoDB

  • Post author:
  • Post category:其他


using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

using MongoDB.Bson;

using MongoDB.Driver;

namespace WebApplication1

{


public partial class index : System.Web.UI.Page

{


protected void Page_Load(object sender, EventArgs e)

{


// 使用连接字符串连接

var client = new MongoClient(“mongodb://localhost:27017”);

var database = client.GetDatabase(“test”);

var collection = database.GetCollection<BsonDocument>(“lml”);

var document = collection.Find(new BsonDocument()).FirstOrDefault();

this.TextBox1.Text = document.ToString();

//Console.WriteLine(document.ToString());

}

}

}



版权声明:本文为sunny_lv原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。