@@ -6,8 +6,7 @@ namespace Belin.Sql.Reflection;
66/// <summary>
77/// Provides information about a database column.
88/// </summary>
9- /// <param name="property">The property information providing the column metadata.</param>
10- public sealed class ColumnInfo ( PropertyInfo property ) {
9+ public sealed class ColumnInfo {
1110
1211 /// <summary>
1312 /// The nullability context.
@@ -27,38 +26,46 @@ public sealed class ColumnInfo(PropertyInfo property) {
2726 /// <summary>
2827 /// Value indicating whether the column value is generated by the database.
2928 /// </summary>
30- public bool IsComputed => databaseGeneratedOption != DatabaseGeneratedOption . None ;
29+ public bool IsComputed { get ; }
3130
3231 /// <summary>
3332 /// Value indicating whether the column value is generated by the database when a row is inserted.
3433 /// </summary>
35- public bool IsIdentity => databaseGeneratedOption == DatabaseGeneratedOption . Identity ;
34+ public bool IsIdentity { get ; }
3635
3736 /// <summary>
3837 /// Value indicating whether the column value is nullable.
3938 /// </summary>
40- public bool IsNullable => Nullable . GetUnderlyingType ( Type ) is not null || nullability . WriteState != NullabilityState . NotNull ;
39+ public bool IsNullable { get ; }
4140
4241 /// <summary>
4342 /// The column name.
4443 /// </summary>
45- public string Name { get ; } = property . GetCustomAttribute < ColumnAttribute > ( ) ? . Name ?? property . Name ;
44+ public string Name { get ; }
4645
4746 /// <summary>
4847 /// The type of the column value.
4948 /// </summary>
5049 public Type Type => property . PropertyType ;
5150
5251 /// <summary>
53- /// Value indicating how the database generates values for this column.
52+ /// The property information providing the column metadata .
5453 /// </summary>
55- private readonly DatabaseGeneratedOption databaseGeneratedOption =
56- property . GetCustomAttribute < DatabaseGeneratedAttribute > ( ) ? . DatabaseGeneratedOption ?? DatabaseGeneratedOption . None ;
54+ private readonly PropertyInfo property ;
5755
5856 /// <summary>
59- /// The nullability information for the underlying property .
57+ /// Creates new column information .
6058 /// </summary>
61- private readonly NullabilityInfo nullability = nullabilityContext . Create ( property ) ;
59+ /// <param name="property">The property information providing the column metadata.</param>
60+ public ColumnInfo ( PropertyInfo property ) {
61+ this . property = property ;
62+
63+ var databaseGeneratedOption = property . GetCustomAttribute < DatabaseGeneratedAttribute > ( ) ? . DatabaseGeneratedOption ?? DatabaseGeneratedOption . None ;
64+ IsComputed = databaseGeneratedOption != DatabaseGeneratedOption . None ;
65+ IsIdentity = databaseGeneratedOption == DatabaseGeneratedOption . Identity ;
66+ IsNullable = Nullable . GetUnderlyingType ( property . PropertyType ) is not null || nullabilityContext . Create ( property ) . WriteState != NullabilityState . NotNull ;
67+ Name = property . GetCustomAttribute < ColumnAttribute > ( ) ? . Name ?? property . Name ;
68+ }
6269
6370 /// <summary>
6471 /// Gets the property value of a specified object.
0 commit comments