コード例 #1
0
        /// <summary>
        /// 生成对象操作
        /// </summary>
        public ActionResult BuilderDAL(E_PageParameter ePageParameter)
        {
            BuilderDALCode    builderDAL = new BuilderDALCode();
            DbObject          db         = new DbObject(ePageParameter.connstring);
            E_DALCode         eDalCode   = new E_DALCode();
            string            tname      = ePageParameter.tablename.Replace(ePageParameter.prefix, "");
            List <ColumnInfo> list       = db.GetColumnInfoList(ePageParameter.dbname, ePageParameter.tablename);

            eDalCode.Fieldlist = list;
            eDalCode.TableName = ePageParameter.tablename;
            eDalCode.ModelName = "E_" + tname.Substring(0, 1).ToUpper() + tname.Substring(1, tname.Length - 1);
            eDalCode.Modelpath = "Model";
            eDalCode.DbObject  = db;
            eDalCode.Keys      = list.Where(a => a.IsPrimaryKey).ToList();
            eDalCode.DALpath   = "DAL";
            eDalCode.DALName   = "D_" + tname.Substring(0, 1).ToUpper() + tname.Substring(1, tname.Length - 1);
            DataRow tableDescRow = db.GetTablesExProperty(ePageParameter.dbname).Select("objname='" + ePageParameter.tablename + "'").FirstOrDefault();

            if (tableDescRow != null)
            {
                eDalCode.TableDescription = tableDescRow["value"]?.ToString();
            }
            builderDAL.eDALCode = eDalCode;
            string modelStr = builderDAL.CreatDAL();

            ViewBag.CodeHtml = modelStr;
            return(PartialView("~/Views/Code/BuilderDAL.cshtml"));
        }
コード例 #2
0
        /// <summary>
        /// 生成对象实体
        /// </summary>
        public ActionResult BuilderModel(E_PageParameter ePageParameter)
        {
            DbObject         db           = new DbObject(ePageParameter.connstring);
            BuilderModelCode builderModel = new BuilderModelCode();
            E_ModelCode      eModelCode   = new E_ModelCode();

            eModelCode.Fieldlist = db.GetColumnInfoList(ePageParameter.dbname, ePageParameter.tablename);
            eModelCode.ModelName = ePageParameter.tablename.Replace(ePageParameter.prefix, "");
            eModelCode.BaseClass = "E_BaseModel";
            DataRow tableDescRow = db.GetTablesExProperty(ePageParameter.dbname).Select("objname='" + ePageParameter.tablename + "'").FirstOrDefault();

            if (tableDescRow != null)
            {
                eModelCode.TableDescription = tableDescRow["value"]?.ToString();
            }
            builderModel.eModelCode = eModelCode;
            string modelStr = builderModel.CreatModel();

            ViewBag.CodeHtml = modelStr;
            return(PartialView("~/Views/Code/BuilderModel.cshtml"));
        }
コード例 #3
0
        /// <summary>
        /// 生成对象控制器
        /// </summary>
        public ActionResult BuilderControllers(E_PageParameter ePageParameter)
        {
            BuilderControllersCode builderControllers = new BuilderControllersCode();
            DbObject          db = new DbObject(ePageParameter.connstring);
            E_ControllersCode eControllersCode = new E_ControllersCode();
            string            tname            = ePageParameter.tablename.Replace(ePageParameter.prefix, "");
            List <ColumnInfo> list             = db.GetColumnInfoList(ePageParameter.dbname, ePageParameter.tablename);

            eControllersCode.primarykeyname = list.Where(a => a.IsPrimaryKey).ToList().First().ColumnName;
            eControllersCode.modelname      = "E_" + tname.Substring(0, 1).ToUpper() + tname.Substring(1, tname.Length - 1);
            eControllersCode.tablename      = tname.Substring(0, 1).ToUpper() + tname.Substring(1, tname.Length - 1);
            DataRow tableDescRow = db.GetTablesExProperty(ePageParameter.dbname).Select("objname='" + ePageParameter.tablename + "'").FirstOrDefault();

            if (tableDescRow != null)
            {
                eControllersCode.tabledescription = tableDescRow["value"]?.ToString();
            }
            builderControllers.eControllersCode = eControllersCode;

            string modelStr = builderControllers.CreatControllers();

            ViewBag.CodeHtml = modelStr;
            return(PartialView("~/Views/Code/BuilderControllers.cshtml"));
        }