/// <summary> /// 获取属性在Field中的类型 /// </summary> private static string GetFieldType(PropertyInfo item) { Type att_type = typeof(SQLFieldAttribute); Attribute a = Attribute.GetCustomAttribute(item, att_type); if (a == null) { return(null); } SQLFieldAttribute sfa = (SQLFieldAttribute)a; return(sfa.Type); }
/// <summary> /// 获取创建表格时的Field字符串 /// </summary> private static string GetFieldString(PropertyInfo item) { Type att_type = typeof(SQLFieldAttribute); Attribute a = Attribute.GetCustomAttribute(item, att_type); if (a == null) { return(null); } SQLFieldAttribute sfa = (SQLFieldAttribute)a; string sql = ""; sql += sfa.Name + " "; sql += sfa.Type + " "; if (sfa.IsPrimaryKey) { sql += "primary key" + " "; } if (sfa.AutoIncrement) { sql += "autoincrement" + " "; } if (sfa.IsNotNull) { sql += "not null" + " "; } if (sfa.IsUnique) { sql += "unique" + " "; } if (sfa.Default != null) { sql += "default " + sfa.Default; } return(sql); }