Inheritance: Noear.Weed.DbContext
コード例 #1
0
ファイル: MainViewModel.cs プロジェクト: noear/Weed3
        public void loadObjects(DbContextEx db)
        {
            ObjectList.Clear();

            //1.获取配置里的执行代码
            //
            ObjectItem exeCode = SourceConfig.GetObject(db.builder, db);

            ObjectModel dataTableRoot = new ObjectModel("数据表", 0);
            ObjectModel dataViewRoot = new ObjectModel("数据视图", 0);
            ObjectModel dataSPRoot = new ObjectModel("存储过程", 0);

            //2.执行代码,获取数据
            //
            List<ObjectModel> tableList = db.sql(exeCode.Table).getList(new ObjectModel(1));
            List<ObjectModel> viewList = db.sql(exeCode.View).getList(new ObjectModel(2));
            List<ObjectModel> spList = db.sql(exeCode.StoredProcedure).getList(new ObjectModel(3));

            //3.绑定到树控件上
            //
            dataTableRoot.AddRange(tableList);
            dataViewRoot.AddRange(viewList);
            dataSPRoot.AddRange(spList);

            if (dataTableRoot.Children.Count > 0)
                ObjectList.Add(dataTableRoot);

            if (dataViewRoot.Children.Count > 0)
                ObjectList.Add(dataViewRoot);

            if (dataSPRoot.Children.Count > 0)
                ObjectList.Add(dataSPRoot);

            NotifyPropertyChanged("ObjectList");
        }
コード例 #2
0
ファイル: DbManager.cs プロジェクト: zhangxl1989/Weed3
        static DbManager() {
            cache = new Dictionary<string, DbContextEx>();

            var list = ConfigurationManager.ConnectionStrings;

            for (int i = 0, len = list.Count; i < len; i++) {
                ConnectionStringSettings p = list[i];

                DbContextEx temp = new DbContextEx(p.Name, p.Name);
                cache.Add(p.Name, temp);
            }
        }
コード例 #3
0
ファイル: DbManager.cs プロジェクト: noear/Weed3
        static DbManager()
        {
            cache = new Dictionary<string, DbContextEx>();

            var list = ConfigurationManager.ConnectionStrings;

            for (int i = 0, len = list.Count; i < len; i++) {
                ConnectionStringSettings p = list[i];

                DbContextEx temp = new DbContextEx(p.Name, p.Name);
                cache.Add(p.Name, temp);
            }
        }
コード例 #4
0
ファイル: MainViewModel.cs プロジェクト: noear/Weed3
        public List<PropertyModel> getPropertyList(DbContextEx db, ObjectModel obj)
        {
            PropertyItem exeCode = SourceConfig.GetProperty(db.builder, db);

            List<PropertyModel> popList = null;

            string sql = null;
            if (obj.Type < 3) {
                sql = exeCode.Table.Replace("{ID}", obj.ID).Replace("{NAME}", obj.Name);
            }
            else {
                sql = exeCode.StoredProcedure.Replace("{ID}", obj.ID).Replace("{NAME}", obj.Name).Trim();

                if (sql[0] == '@')
                    popList = Weed.Addin.Eval<IParamsBuilder>(sql.Substring(1)).GetParams(obj.Name, db);
            }

            if (popList == null)
                popList = db.sql(sql).getList(new PropertyModel());

            return popList;
        }
コード例 #5
0
ファイル: MainViewModel.cs プロジェクト: noear/Weed3
        public void loadPropertys(DbContextEx db, ObjectModel obj)
        {
            var popList = getPropertyList(db, obj);

            PropertyList.Clear();
            foreach (var p in popList)
                PropertyList.Add(p);
        }
コード例 #6
0
ファイル: MainWindow.xaml.cs プロジェクト: noear/Weed3
 private void sourceBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     currentSource = DbManager.get((string)sourceBox.SelectedItem);
     viewModel.loadObjects(currentSource);
 }
コード例 #7
0
ファイル: SourceConfig.cs プロジェクト: noear/Weed3
        public static PropertyItem GetProperty(string name, DbContextEx db)
        {
            PropertyItem temp = new PropertyItem();

            string opsXml = __Config[name]["Property"].OuterText;

            if (opsXml.IndexOf("{db}") > 0)
                opsXml = opsXml.Replace("{db}", db.getSchema());

            XDom.Bind(temp, opsXml);

            if (temp.View.Trim().IndexOf(" ") < 0)
                temp.View = temp.Table;

            return temp;
        }
コード例 #8
0
ファイル: SourceConfig.cs プロジェクト: noear/Weed3
        public static ObjectItem GetObject(string name, DbContextEx db)
        {
            ObjectItem temp = new ObjectItem();

            string opsXml = __Config[name]["Object"].OuterText;

            if (opsXml.IndexOf("{db}") > 0)
                opsXml = opsXml.Replace("{db}", db.getSchema());

            XDom.Bind(temp, opsXml);

            return temp;
        }
コード例 #9
0
ファイル: WeedBuilder.cs プロジェクト: noear/Weed3
 public WeedBuilder(DbContextEx db)
 {
     this.db = db;
 }