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; }
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() }; }
/// <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; }
public MResult<Dictionary<string, string>> GenneratorModelList(MDataBaseDefine db, string namespaceStr) { MResult<Dictionary<string, string>> ret = new MResult<Dictionary<string, string>>(); return ret; }
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(); }