コード例 #1
0
ファイル: test.aspx.cs プロジェクト: hablan/Mainline
        protected void btnGetConnlections_Click(object sender, EventArgs e)
        {
            BsonDocument docFind = new BsonDocument();

            MongoDB.Driver.MongoServer server = MongoDB.Driver.MongoServer.Create(ConfigurationManager.AppSettings["mongoDBConfig"]);
            server.Connect();
            //获取指定数据库
            MongoDB.Driver.MongoDatabase db = server.GetDatabase(ConfigurationManager.AppSettings["mongoDBName"].ToString());
            string collection = txtCollection.Text.Trim();

            //获取表
            MongoDB.Driver.MongoCollection <BsonDocument> col = db.GetCollection <BsonDocument>(collection);
            lblCollections.Text = "表大小:" + col.GetTotalDataSize() / (1024 * 1024) + "M";//db['119004logs'].totalIndexSize()+db['119004logs'].dataSize()
            this.listBoxCollections.DataSource = col.Database.GetCollectionNames();
            listBoxCollections.DataBind();

            lblDataBaseCount.Text = "数据库大小为:" + db.GetStats().StorageSize / (1024 * 1024) + "M";
        }
コード例 #2
0
ファイル: test.aspx.cs プロジェクト: hablan/Mainline
        protected void btnGetIndex_Click(object sender, EventArgs e)
        {
            BsonDocument docFind = new BsonDocument();

            MongoDB.Driver.MongoServer server = MongoDB.Driver.MongoServer.Create(ConfigurationManager.AppSettings["mongoDBConfig"]);
            server.Connect();
            //获取指定数据库
            MongoDB.Driver.MongoDatabase db = server.GetDatabase(ConfigurationManager.AppSettings["mongoDBName"].ToString());
            string collection = txtCollection.Text.Trim();

            //获取表
            MongoDB.Driver.MongoCollection <BsonDocument> col = db.GetCollection <BsonDocument>(collection);
            GetIndexesResult indexsResult = col.GetIndexes();
            string           strIndexs    = string.Empty;

            for (int i = 0; i < indexsResult.Count; i++)
            {
                strIndexs += indexsResult[i].Key.ToString() + ";";
            }
            txtGetIndexs.Text = strIndexs;
        }
コード例 #3
0
ファイル: VF_MongoDB.cs プロジェクト: conan513/RealmPlayers
 public MongoCollection(MongoDB.Driver.MongoCollection <T_CollectionType> _Collection, MongoDatabase _Parent)
 {
     m_Collection = _Collection;
     m_Parent     = _Parent;
 }