示例#1
0
 public DBUpdateItem(string TableName)
 {
     if (TableName == "")
     {
         update_type = DBUpdateType.Sql;
     }
     else
     {
         update_type = DBUpdateType.DeleteColumn;
     }
     table_name  = TableName;
     column_info = null;
 }
示例#2
0
 public DBUpdateItem(string TableName, DBDataType DataType, int Length, int Length2, string DefaultValue, bool AllowNull, bool IsPrimary, bool IsIdentity, string Description, bool JsonIgnore)
 {
     if (TableName == "")
     {
         update_type = DBUpdateType.Sql;
     }
     else
     {
         update_type = DBUpdateType.AddColumn;
     }
     table_name  = TableName;
     column_info = new DBColumn("", DataType, Length, Length2, DefaultValue, AllowNull, IsPrimary, IsIdentity, Description, JsonIgnore);
 }
示例#3
0
        public DBColumn Copy()
        {
            DBColumn col = new DBColumn(name, data_type, data_length);

            col.data_length2     = data_length2;
            col.default_value    = default_value;
            col.allow_null       = allow_null;
            col.is_identity      = is_identity;
            col.is_primary       = is_primary;
            col.data_description = data_description;
            col.field_info       = field_info;
            col.json_ignore      = json_ignore;
            col.replace_name     = replace_name;
            return(col);
        }
示例#4
0
        /// <summary>
        /// 获取当前需要更新的sql语句
        /// </summary>
        /// <param name="db_type">数据库类型</param>
        /// <returns></returns>
        public List <string> getUpdateSqlList(DBType db_type)
        {
            List <string> sql_list = new List <string>();

            FieldInfo[] fields = this.GetType().GetFields();
            foreach (FieldInfo fi in fields)
            {
                try
                {
                    if (fi.FieldType != typeof(string))
                    {
                        continue;
                    }
                    var item = fi.getAttribute <DBUpdateItem>();
                    if (item != null)
                    {
                        string value = fi.GetValue(this) as string;
                        if (value.Trim() == "")
                        {
                            continue;
                        }
                        switch (item.update_type)
                        {
                        case DBUpdateType.Sql:
                        default:
                            sql_list.Add(value);
                            break;

                        case DBUpdateType.DeleteColumn:
                            DBColumn column = new DBColumn(value, DBDataType.Bit, 0);
                            sql_list.Add(column.getDeleteColumnSql(db_type, item.table_name));
                            break;

                        case DBUpdateType.AddColumn:
                            item.column_info.allow_null = true;    //新增列如果不允许空时插入不进去, 所以需要强制设置为允许空
                            item.column_info.name       = value;
                            sql_list.Add(item.column_info.getAddColumnSql(db_type, item.table_name));
                            break;
                        }
                    }
                }
                catch { }
            }
            return(sql_list);
        }
示例#5
0
 public DBQueryParam(DBTable table, string column_name, object value)
 {
     column     = table.columnWithName(column_name);
     this.value = value;
 }
示例#6
0
 public DBQueryParam(DBColumn column, object value)
 {
     this.column = column;
     this.value  = value;
 }
示例#7
0
 public DBUpdateItem(DBUpdateType UpdateType, string TableName)
 {
     update_type = UpdateType;
     table_name  = TableName;
     column_info = null;
 }
示例#8
0
 public DBUpdateItem(DBUpdateType UpdateType)
 {
     update_type = UpdateType;
     table_name  = "";
     column_info = null;
 }
示例#9
0
 public DBUpdateItem()
 {
     update_type = DBUpdateType.Sql;
     table_name  = "";
     column_info = null;
 }