Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 3
0
        public string SqlSelect(string tableName, List <FieldInfo> fields)
        {
            string sql = "Select " + FactoryHelper.CreateFieldList(fields, true, true, "") + " From " + tableName + " Where ";

            return(sql);
        }
Exemplo n.º 4
0
 public string SqlAllFields(List <FieldInfo> fields)
 {
     return(FactoryHelper.CreateFieldList(fields, true, true, ""));
 }