@@ -66,7 +66,7 @@ public static List<string> GetIdentityColumns(Type type)
6666 identityColumns = CacheManager . GetTypeProperties ( type )
6767 . Where ( prop =>
6868 Attribute . IsDefined ( prop , typeof ( KeyPropertyAttribute ) ) &&
69- ( ( KeyPropertyAttribute ) Attribute . GetCustomAttribute ( prop , typeof ( KeyPropertyAttribute ) ) ) . IsPrimaryKey
69+ ( ( KeyPropertyAttribute ) Attribute . GetCustomAttribute ( prop , typeof ( KeyPropertyAttribute ) ) ! ) . IsPrimaryKey
7070 ) . Select ( prop => prop . Name ) . ToList ( ) ;
7171
7272
@@ -92,7 +92,7 @@ public static List<string> GetKeyColumns(Type type)
9292 keyColumns = GetTypeProperties ( type )
9393 . Where ( prop =>
9494 Attribute . IsDefined ( prop , typeof ( KeyPropertyAttribute ) ) &&
95- ( ( KeyPropertyAttribute ) Attribute . GetCustomAttribute ( prop , typeof ( KeyPropertyAttribute ) ) ) . KeyProperty
95+ ( ( KeyPropertyAttribute ) Attribute . GetCustomAttribute ( prop , typeof ( KeyPropertyAttribute ) ) ! ) . KeyProperty
9696 ) . Select ( prop => prop . Name ) . ToList ( ) ;
9797
9898 typeCaches . Add ( nameof ( CachePropertyType . Key ) , keyColumns ) ;
@@ -103,9 +103,9 @@ public static List<string> GetKeyColumns(Type type)
103103 /// <summary>
104104 /// Gets the names of properties marked as excluded properties for a specified type.
105105 /// </summary>
106- /// <param name="type">The type for which to retrieve excluded properties .</param>
107- /// <returns>A list of excluded property names.</returns>
108- public static List < string > GetExcludedProperties ( Type type )
106+ /// <param name="type">The type for which to retrieve excluded columns .</param>
107+ /// <returns>A list of excluded column names.</returns>
108+ public static List < string > GetExcludedColumns ( Type type )
109109 {
110110 var typeCaches = GetOrCreateDictionary ( type ) ;
111111
@@ -114,11 +114,7 @@ public static List<string> GetExcludedProperties(Type type)
114114 return ( List < string > ) excludedProperties ;
115115 }
116116
117- excludedProperties = GetTypeProperties ( type )
118- . Where ( prop =>
119- Attribute . IsDefined ( prop , typeof ( ExcludedPropertyAttribute ) ) &&
120- ( ( ExcludedPropertyAttribute ) Attribute . GetCustomAttribute ( prop , typeof ( ExcludedPropertyAttribute ) ) ) . Excluded
121- ) . Select ( prop => prop . Name ) . ToList ( ) ;
117+ excludedProperties = GetExcludedProperties ( type ) . Select ( prop => prop . Name ) . ToList ( ) ;
122118
123119 typeCaches . Add ( nameof ( CachePropertyType . Excluded ) , excludedProperties ) ;
124120
@@ -194,9 +190,9 @@ public static string GetTableName(Type type)
194190 else
195191 TableSchema = null ;
196192
197- typeCaches . Add ( nameof ( CachePropertyType . TableSchema ) , TableSchema ) ;
193+ typeCaches . Add ( nameof ( CachePropertyType . TableSchema ) , TableSchema ! ) ;
198194
199- return ( string ) TableSchema ;
195+ return ( string ? ) TableSchema ;
200196 }
201197
202198 /// <summary>
@@ -266,14 +262,67 @@ public static PropertyInfo[] GetComparableProperties(Type type)
266262 }
267263
268264 var keyProps = GetKeyColumns ( type ) ;
269- var excludeProps = GetExcludedProperties ( type ) ;
265+ var excludeProps = GetExcludedColumns ( type ) ;
270266
271267 _properties = GetTypeProperties ( type ) . Where ( prop => ! keyProps . Contains ( prop . Name ) && ! excludeProps . Contains ( prop . Name ) ) . ToArray ( ) ;
272268
273269 return ( PropertyInfo [ ] ) _properties ;
274270
275271 }
276272
273+ /// <summary>
274+ /// Gets the properties that are unique for a specified type.
275+ /// </summary>
276+ /// <param name="type">The type for which to retrieve unique properties.</param>
277+ /// <returns>An array of <see cref="PropertyInfo"/> objects representing unique properties of the specified type.</returns>
278+ public static PropertyInfo [ ] GetKeyProperties ( Type type )
279+ {
280+ var typeCaches = GetOrCreateDictionary ( type ) ;
281+
282+ if ( typeCaches . TryGetValue ( nameof ( CachePropertyType . KeyProperties ) , out var _properties ) )
283+ {
284+ return ( PropertyInfo [ ] ) _properties ;
285+ }
286+
287+ var keyProps = GetKeyColumns ( type ) ;
288+ var excludeProps = GetExcludedColumns ( type ) ;
289+
290+ _properties = GetTypeProperties ( type )
291+ . Where ( prop =>
292+ Attribute . IsDefined ( prop , typeof ( KeyPropertyAttribute ) ) &&
293+ ( ( KeyPropertyAttribute ) Attribute . GetCustomAttribute ( prop , typeof ( KeyPropertyAttribute ) ) ! ) . KeyProperty
294+ ) . ToArray ( ) ;
295+
296+ return ( PropertyInfo [ ] ) _properties ;
297+
298+ }
299+
300+ /// <summary>
301+ /// Gets the excluded properties for a specified type.
302+ /// </summary>
303+ /// <param name="type">The type for which to retrieve the excluded properties.</param>
304+ /// <returns>An array of <see cref="PropertyInfo"/> representing the excluded properties for the specified type.</returns>
305+ public static PropertyInfo [ ] GetExcludedProperties ( Type type )
306+ {
307+ var typeCaches = GetOrCreateDictionary ( type ) ;
308+
309+ if ( typeCaches . TryGetValue ( nameof ( CachePropertyType . ExcludedProperties ) , out var _properties ) )
310+ {
311+ return ( PropertyInfo [ ] ) _properties ;
312+ }
313+
314+ var keyProps = GetKeyColumns ( type ) ;
315+
316+ _properties = GetTypeProperties ( type )
317+ . Where ( prop =>
318+ Attribute . IsDefined ( prop , typeof ( ExcludedPropertyAttribute ) ) &&
319+ ( ( ExcludedPropertyAttribute ) Attribute . GetCustomAttribute ( prop , typeof ( ExcludedPropertyAttribute ) ) ! ) . Excluded
320+ ) . ToArray ( ) ;
321+
322+ return ( PropertyInfo [ ] ) _properties ;
323+
324+ }
325+
277326 /// <summary>
278327 /// Disposes of cached data associated with the specified type.
279328 /// </summary>
0 commit comments