public MongoProfileContext(uint id)
        {
            var dbNode = MongoCache.GetTreeNode(id);

            Database = MongoCache.GetMongoObject(id) as MongoDatabaseModel;
            var serverNode = MongoCache.GetTreeNode(dbNode.PID);

            Server = MongoCache.GetMongoObject(serverNode.ID) as MongoServerModel;
        }
Exemple #2
0
        public MongoCollectionInfo(uint id)
        {
            var tbNode = MongoCache.GetTreeNode(id);

            Table = MongoCache.GetMongoObject(id) as MongoCollectionModel;
            var dbNode = MongoCache.GetTreeNode(tbNode.PID);

            Database = MongoCache.GetMongoObject(dbNode.ID) as MongoDatabaseModel;
            var serverNode = MongoCache.GetTreeNode(dbNode.PID);

            Server = MongoCache.GetMongoObject(serverNode.ID) as MongoServerModel;
        }
        /// <summary>
        /// 获取索引信息
        /// </summary>
        /// <returns></returns>
        public List <MongoIndexModel> GetIndexes()
        {
            var list = MongoCache.GetTreeNodes().Where(node => node.PID == ID).ToList();

            var indexes = new List <MongoIndexModel>();

            foreach (var item in list)
            {
                indexes.Add(MongoCache.GetMongoObject(item.ID) as MongoIndexModel);
            }
            return(indexes);
        }
        public List <MongoFieldModel> GetFields()
        {
            var fieldNodes = MongoCache.GetTreeNodes().Where(n => n.PID == ID).ToList();

            var list = new List <MongoFieldModel>();

            foreach (var node in fieldNodes)
            {
                list.Add(MongoCache.GetMongoObject(node.ID) as MongoFieldModel);
            }
            return(list);
        }
        /// <summary>
        /// 删除索引
        /// </summary>
        /// <param name="name"></param>
        public void DeleteIndex(uint id)
        {
            var mongo  = new MongoClient(string.Format(MongoConst.ConnString, Server.Name));
            var server = mongo.GetServer();
            var db     = server.GetDatabase(Database.Name);

            var idx = MongoCache.GetMongoObject(id) as MongoIndexModel;
            var tbl = db.GetCollection(Table.Name);

            tbl.DropIndex(idx.Keys.Select(k => k.FieldName).ToArray());

            MongoCache.Clear();
        }
        public MongoIndexContext(uint id)
        {
            ID = id;
            var idxNode = MongoCache.GetTreeNode(ID);

            var tbNode = MongoCache.GetTreeNode(idxNode.PID);

            Table = MongoCache.GetMongoObject(tbNode.ID) as MongoCollectionModel;
            var dbNode = MongoCache.GetTreeNode(tbNode.PID);

            Database = MongoCache.GetMongoObject(dbNode.ID) as MongoDatabaseModel;
            var serverNode = MongoCache.GetTreeNode(dbNode.PID);

            Server = MongoCache.GetMongoObject(serverNode.ID) as MongoServerModel;
        }
        public MongoReplicationContext(uint id)
        {
            var serverNode = MongoCache.GetTreeNode(id);

            Server = MongoCache.GetMongoObject(serverNode.ID) as MongoServerModel;
        }
 public MongoServerInfo(uint id)
 {
     Server = MongoCache.GetMongoObject(id) as MongoServerModel;
 }