public string SqlInsert(string tableName, List <FieldInfo> fields) { //Oracle没有自增字段,如果检测到自增字段,则替换 string currentID = "PK_SEQ_" + tableName + ".NEXTVAL"; string sql = "Insert Into " + tableName + " ("; sql = sql + FactoryHelper.CreateFieldList(fields, true, false, ""); sql = sql + ")Values(" + FactoryHelper.CreateFieldList(fields, true, false, ParaSymbol) + ")"; sql = sql.Replace(ParaSymbol + AUTO_INCREASE_FIELD, currentID); return(sql); }
public string SqlInsert(string tableName, List <FieldInfo> fields) { FieldInfo pk = fields.Find(s => s.IsPrimaryKey); if (pk == null) { return(""); } string sql = "Insert Into " + tableName + " ("; //如果主键是自增,则不包括主键和自增 if (pk.IsAutoIncrease) { sql = sql + FactoryHelper.CreateFieldList(fields, false, false, ""); sql = sql + ")Values(" + FactoryHelper.CreateFieldList(fields, false, false, ParaSymbol) + ")"; } else { //如果主键不是自增,则必须手动输入主键,因此包括主键字段 sql = sql + FactoryHelper.CreateFieldList(fields, true, false, ""); sql = sql + ")Values(" + FactoryHelper.CreateFieldList(fields, true, false, ParaSymbol) + ")"; } return(sql); }
/// <summary> /// SqlDataReader 获得值,生成形如model.ID=sdr.GetInt32(0);model.Name=sdr.getString(1);这种语句 /// </summary> /// <param name="fields"></param> /// <returns></returns> private string ReaderGetValList(List <FieldInfo> fields) { return(FactoryHelper.ReaderGetValList(fields, factory)); }
private string CreateParaForUpdate(List <FieldInfo> fields) { return(FactoryHelper.CreateParaForUpdate(fields, factory)); }
/// <summary> /// 返回左侧的空格 /// </summary> /// <param name="num">单位1代表4个空格,相当于Tab</param> /// <returns></returns> private string Pad(int num) { return(FactoryHelper.Pad(num)); }
/// <summary> /// 构造函数 /// </summary> /// <param name="pro">项目实例</param> public CodeMaker(ProjectInfo pro) { this.pro = pro; this.factory = FactoryHelper.CreateFactory(pro); }
public string SqlSelect(string tableName, List <FieldInfo> fields) { string sql = "Select " + FactoryHelper.CreateFieldList(fields, true, true, "") + " From " + tableName + " Where "; return(sql); }
public string SqlUpdate(string tableName, List <FieldInfo> fields) { string sql = "Update " + tableName + " Set " + FactoryHelper.CreateUpdateFieldList(fields, ParaSymbol) + " Where "; return(sql); }
public string SqlAllFields(List <FieldInfo> fields) { return(FactoryHelper.CreateFieldList(fields, true, true, "")); }
public string NameFormat(string name) { return(FactoryHelper.NameFormat(name, pro.IsNameSplitWithUnderLine)); }