示例#1
0
        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);
        }
示例#2
0
        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);
        }
示例#3
0
 /// <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));
 }
示例#4
0
 private string CreateParaForUpdate(List <FieldInfo> fields)
 {
     return(FactoryHelper.CreateParaForUpdate(fields, factory));
 }
示例#5
0
 /// <summary>
 /// 返回左侧的空格
 /// </summary>
 /// <param name="num">单位1代表4个空格,相当于Tab</param>
 /// <returns></returns>
 private string Pad(int num)
 {
     return(FactoryHelper.Pad(num));
 }
示例#6
0
 /// <summary>
 ///  构造函数
 /// </summary>
 /// <param name="pro">项目实例</param>
 public CodeMaker(ProjectInfo pro)
 {
     this.pro     = pro;
     this.factory = FactoryHelper.CreateFactory(pro);
 }
示例#7
0
        public string SqlSelect(string tableName, List <FieldInfo> fields)
        {
            string sql = "Select " + FactoryHelper.CreateFieldList(fields, true, true, "") + " From " + tableName + " Where ";

            return(sql);
        }
示例#8
0
        public string SqlUpdate(string tableName, List <FieldInfo> fields)
        {
            string sql = "Update " + tableName + " Set " + FactoryHelper.CreateUpdateFieldList(fields, ParaSymbol) + " Where ";

            return(sql);
        }
示例#9
0
 public string SqlAllFields(List <FieldInfo> fields)
 {
     return(FactoryHelper.CreateFieldList(fields, true, true, ""));
 }
示例#10
0
 public string NameFormat(string name)
 {
     return(FactoryHelper.NameFormat(name, pro.IsNameSplitWithUnderLine));
 }