예제 #1
0
        private bool CheckGeneratorSQL(MDataBaseDefine db, out string errorMsg)
        {
            if (db == null)
            {
                errorMsg = "待处理的数据为空";
                return false;
            }

            if (string.IsNullOrEmpty(db.DataBaseName))
            {
                errorMsg = "数据库名称为空";
                return false;
            }

            string msg = string.Empty;

            if (!this.CheckGeneratorSQL(db.TableList, out msg))
            {
                errorMsg = msg;
                return false;
            }

            errorMsg = string.Empty;
            return true;
        }
예제 #2
0
        public MResult<string> GeneratorSQL(MDataBaseDefine db)
        {
            // 1、进行数据验证
            string errorMsg = string.Empty;
            if (!this.CheckGeneratorSQL(db, out errorMsg))
            {
                return new MResult<string>()
                {
                    ErrorMsg = errorMsg,
                    IsSuccess = false,
                    Result = string.Empty,
                };
            }

            string databaseSQL = this.GetCreateDataBaseSQL(db);

            StringBuilder tableSQL = new StringBuilder();
            foreach (var table in db.TableList)
            {
                string str = this.GetCreateTableSQL(table);
                tableSQL.Append(str).AppendLine();
            }

            return new MResult<string>
            {
                IsSuccess = true,
                ErrorMsg = string.Empty,
                Result = databaseSQL.ToString() + tableSQL.ToString()
            };
        }
예제 #3
0
 /// <summary>
 /// 生成SQL语句
 /// </summary>
 /// <param name="db">数据库定义</param>
 /// <returns>结果</returns>
 public MResult<string> GeneratorSQL(MDataBaseDefine db)
 {
     var dao = DALFactory.GetGeneratorSQLDAL(db.DataBaseType);
     var ret = dao.GeneratorSQL(db);
     return ret;
 }
예제 #4
0
        public MResult<Dictionary<string, string>> GenneratorModelList(MDataBaseDefine db, string namespaceStr)
        {
            MResult<Dictionary<string, string>> ret = new MResult<Dictionary<string, string>>();

            return ret;
        }
예제 #5
0
        private string GetCreateDataBaseSQL(MDataBaseDefine db)
        {
            StringBuilder sb = new StringBuilder();
            sb.AppendFormat("/* 建立数据库{0} */", db.DataBaseName).AppendLine();
            sb.AppendFormat("CREATE DATABASE {0} DEFAULT charset utf8 collate utf8_general_ci;", db.DataBaseName).AppendLine();

            return sb.ToString();
        }