摘要:MongoDB (查詢)
繼上個問題...總算找到一個解決方法
如何在芒果Mnogodb 下select * from talbe
參考網頁 (c#命令提示字元範例)
小弟依舊 WIN 7 SV2010 (web) Mongodb1.4.3
db.user.find() = select * from table
小弟總算給他搞定了
01 using MongoDB.Driver;
02
03 public partial class _Default : System.Web.UI.Page
04 {
05 protected void Page_Load(object sender, EventArgs e)
06 {
07 Mongo db = new Mongo();
08 db.Connect(); // 連接伺服器
09 Database test = db.GetDatabase("test");// 獲取資料庫
10 IMongoCollection things = test.GetCollection("things"); // 獲取欄位集合
11 ICursor cur = things.FindAll();
12 foreach (Document iDoc in cur.Documents)
13 {
14 Response.Write(iDoc + "<p/>");
15 }
16 db.Disconnect();
17 }
18 }
02
03 public partial class _Default : System.Web.UI.Page
04 {
05 protected void Page_Load(object sender, EventArgs e)
06 {
07 Mongo db = new Mongo();
08 db.Connect(); // 連接伺服器
09 Database test = db.GetDatabase("test");// 獲取資料庫
10 IMongoCollection things = test.GetCollection("things"); // 獲取欄位集合
11 ICursor cur = things.FindAll();
12 foreach (Document iDoc in cur.Documents)
13 {
14 Response.Write(iDoc + "<p/>");
15 }
16 db.Disconnect();
17 }
18 }
大家一起加入blogads 賺零用錢!!