public void GenerateSql(DDLConfig dDLConfig, string outputpath) { init(dDLConfig.MyDBType); dDLConfig.Prepare(); string result = String.Empty; dDLConfig.Tables.ForEach(t => { result += templates[dDLConfig.MyDBType.ToString()].Run(instance => { instance.Model = t; }); }); Console.WriteLine(result); if (File.Exists(outputpath)) { File.Delete(outputpath); } File.WriteAllText(outputpath, result, new UTF8Encoding(false)); }
/// <summary> /// user_name -> userName /// userName -> userName /// </summary> /// <param name="c"></param> /// <returns></returns> internal static string GetFieldName(DDLColumn c) { DDLConfig ddlconfig = c.DDLTable.DDLConfig; if (ddlconfig.UnifyName) return c.Name; string columnName = c.NameSql; string[] parts = columnName.Split(ddlconfig.DBColSeparator[0]); string result = ""; for (int i = 0; i < parts.Length; i++) { string partStr = parts[i]; if (string.IsNullOrEmpty(partStr)) { continue; } if (i == 0) { result += partStr; } else { result += (partStr.Substring(0, 1).ToUpper() + (partStr.Length == 1 ? "" : partStr.Substring(1))); } } return result; }
public void Init() { ddlConfig = new DDLConfig(); ddlConfig.MyDBType = DDLConfig.DBType.MySql; DDLTable newtable; DDLColumn column; ddlConfig.Tables.Add(newtable = new DDLTable("base_info", "wx_user", "微信用户")); newtable.Columns.Add(new DDLColumn("id", "id", "varchar(64)", "Y", "")); newtable.Columns.Add(column = new DDLColumn("unionid", "unionid", "varchar(255)", "", "")); column.UniqueKeySign = "Y"; newtable.Columns.Add(new DDLColumn("用户昵称", "nickName", "varchar(255)", "", "")); newtable.Columns.Add(new DDLColumn("用户头像图片的 URL", "avatarUrl", "varchar(500)", "", "")); }
public void Init() { ddlConfig = new DDLConfig(); ddlConfig.MyDBType = DDLConfig.DBType.MySql; DDLTable newtable; DDLColumn column; ddlConfig.Tables.Add(newtable = new DDLTable("wintop_cbs", "cbs_callback", "查博士回调")); newtable.Columns.Add(new DDLColumn("id", "id", "bigint", "是", "")); newtable.Columns.Add(new DDLColumn("单据类型", "order_type", "varchar(50)", "", "")); newtable.Columns.Add(new DDLColumn("调用记录", "invoke_log_id", "bigint", "", "")); newtable.Columns.Add(new DDLColumn("orderId", "order_id", "varchar(50)", "", "")); newtable.Columns.Add(new DDLColumn("结果码", "result", "varchar(50)", "", "")); newtable.Columns.Add(new DDLColumn("结果描述", "message", "varchar(500)", "", "")); newtable.Columns.Add(new DDLColumn("退款方式", "refund_type", "varchar(50)", "", "")); newtable.Columns.Add(new DDLColumn("创建日期", "cre_time", "datetime", "", "")); }