@@ -75,7 +75,7 @@ internal static ModelDefinition GetModelDefinition(this Type modelType)
75
75
var objProperties = modelType . GetProperties (
76
76
BindingFlags . Public | BindingFlags . Instance ) . ToList ( ) ;
77
77
78
- var hasPkAttr = objProperties . Any ( p => p . HasAttribute < PrimaryKeyAttribute > ( ) ) ;
78
+ var hasPkAttr = objProperties . Any ( p => p . HasAttributeCached < PrimaryKeyAttribute > ( ) ) ;
79
79
80
80
var hasIdField = CheckForIdField ( objProperties ) ;
81
81
@@ -107,15 +107,17 @@ internal static ModelDefinition GetModelDefinition(this Type modelType)
107
107
: propertyInfo . PropertyType ;
108
108
109
109
Type treatAsType = null ;
110
- if ( propertyType . IsEnumFlags ( ) || propertyType . HasAttribute < EnumAsIntAttribute > ( ) )
110
+ if ( propertyType . IsEnumFlags ( ) || propertyType . HasAttributeCached < EnumAsIntAttribute > ( ) )
111
111
treatAsType = Enum . GetUnderlyingType ( propertyType ) ;
112
+ else if ( propertyType . HasAttributeCached < EnumAsCharAttribute > ( ) )
113
+ treatAsType = typeof ( char ) ;
112
114
113
115
var isReference = referenceAttr != null && propertyType . IsClass ;
114
- var isIgnored = propertyInfo . HasAttribute < IgnoreAttribute > ( ) || isReference ;
116
+ var isIgnored = propertyInfo . HasAttributeCached < IgnoreAttribute > ( ) || isReference ;
115
117
116
118
var isFirst = ! isIgnored && i ++ == 0 ;
117
119
118
- var isAutoId = propertyInfo . HasAttribute < AutoIdAttribute > ( ) ;
120
+ var isAutoId = propertyInfo . HasAttributeCached < AutoIdAttribute > ( ) ;
119
121
120
122
var isPrimaryKey = ( ! hasPkAttr && ( propertyInfo . Name == OrmLiteConfig . IdField || ( ! hasIdField && isFirst ) ) )
121
123
|| propertyInfo . HasAttributeNamed ( typeof ( PrimaryKeyAttribute ) . Name )
@@ -149,21 +151,21 @@ internal static ModelDefinition GetModelDefinition(this Type modelType)
149
151
IsPrimaryKey = isPrimaryKey ,
150
152
AutoIncrement =
151
153
isPrimaryKey &&
152
- propertyInfo . HasAttribute < AutoIncrementAttribute > ( ) ,
154
+ propertyInfo . HasAttributeCached < AutoIncrementAttribute > ( ) ,
153
155
AutoId = isAutoId ,
154
156
IsIndexed = ! isPrimaryKey && isIndex ,
155
157
IsUniqueIndex = isUnique ,
156
158
IsClustered = indexAttr ? . Clustered == true ,
157
159
IsNonClustered = indexAttr ? . NonClustered == true ,
158
160
IndexName = indexAttr ? . Name ,
159
161
IsRowVersion = isRowVersion ,
160
- IgnoreOnInsert = propertyInfo . HasAttribute < IgnoreOnInsertAttribute > ( ) ,
161
- IgnoreOnUpdate = propertyInfo . HasAttribute < IgnoreOnUpdateAttribute > ( ) ,
162
- ReturnOnInsert = propertyInfo . HasAttribute < ReturnOnInsertAttribute > ( ) ,
162
+ IgnoreOnInsert = propertyInfo . HasAttributeCached < IgnoreOnInsertAttribute > ( ) ,
163
+ IgnoreOnUpdate = propertyInfo . HasAttributeCached < IgnoreOnUpdateAttribute > ( ) ,
164
+ ReturnOnInsert = propertyInfo . HasAttributeCached < ReturnOnInsertAttribute > ( ) ,
163
165
FieldLength = stringLengthAttr ? . MaximumLength ,
164
166
DefaultValue = defaultValueAttr ? . DefaultValue ,
165
167
CheckConstraint = chkConstraintAttr ? . Constraint ,
166
- IsUniqueConstraint = propertyInfo . HasAttribute < UniqueAttribute > ( ) ,
168
+ IsUniqueConstraint = propertyInfo . HasAttributeCached < UniqueAttribute > ( ) ,
167
169
ForeignKey = fkAttr == null
168
170
? referencesAttr != null ? new ForeignKeyConstraint ( referencesAttr . Type ) : null
169
171
: new ForeignKeyConstraint ( fkAttr . Type , fkAttr . OnDelete , fkAttr . OnUpdate , fkAttr . ForeignKeyName ) ,
0 commit comments