public static string BuildFilter(ArgsHelper args) { StringBuilder st = new StringBuilder(""); if (!string.IsNullOrEmpty(args.TableName) && args.TableName != "*") { st.Append(string.Format("a.Name like '{0}%'", args.TableName)); } if (!string.IsNullOrEmpty(args.TableModifyBefore)) { if (st.Length == 0) { st.Append(string.Format("a.modify_date <= '{0}'", args.TableModifyBefore)); } else { st.Append(string.Format(" and a.modify_date <= '{0}'", args.TableModifyBefore)); } } if (!string.IsNullOrEmpty(args.TableModifyAfter)) { if (st.Length == 0) { st.Append(string.Format("a.modify_date >= '{0}'", args.TableModifyAfter)); } else { st.Append(string.Format(" and a.modify_date >= '{0}'", args.TableModifyAfter)); } } return st.ToString(); }
static void Main(string[] args) { string a= "\""; //获取命令行参数 CodeGenerator.MetadataModel.ArgsHelper pars = new CodeGenerator.MetadataModel.ArgsHelper(args); GlobalVariable par = new GlobalVariable(); par.Creater = pars.Creator; par.Copyright = pars.CopyrightTeamName; string strFilter = SqlMetaData.SqlStandard.BuildFilter(pars); string ConfName = ConfigurationManager.AppSettings["ConfName"].ToString(); Conf conf = ConfFactory.CurrentConf(ConfName); MetaDataFactory factory = new MetaDataFactory(conf, par); //获取元数据定义 List<TableDef> tabs = factory.GetMetaData(strFilter); //判定 foreach (TableDef tb in tabs) { factory.CreateAllFile(false,tb); System.Console.WriteLine("生成代码{0}成功;\n",tb.Name); } //输出文件 foreach (TableDef tb in tabs) { //factory.CreateAllFile(false,tb); } }