@@ -109,11 +109,6 @@ internal static TableInfo GetTableByEntity(Type entity, CommonUtils common) {
109109 if ( tmpLt . Contains ( "BYTE" ) ) tmpLt = tmpLt . Replace ( "BYTE" , " BYTE" ) ;
110110 return tmpLt ;
111111 } ) ;
112- colattr . DbDefautValue = trytb . Properties [ p . Name ] . GetValue ( Activator . CreateInstance ( trytb . Type ) ) ;
113- if ( colattr . DbDefautValue != null && p . PropertyType != colattr . MapType ) colattr . DbDefautValue = Utils . GetDataReaderValue ( colattr . MapType , colattr . DbDefautValue ) ;
114- if ( colattr . DbDefautValue == null ) colattr . DbDefautValue = tp ? . defaultValue ;
115- if ( colattr . IsNullable == false && colattr . DbDefautValue == null )
116- colattr . DbDefautValue = Activator . CreateInstance ( colattr . MapType . IsNullableType ( ) ? colattr . MapType . GenericTypeArguments . FirstOrDefault ( ) : colattr . MapType ) ;
117112 if ( colattr . IsIdentity == true && colattr . MapType . IsNumberType ( ) == false )
118113 colattr . IsIdentity = false ;
119114 if ( setMethod == null ) colattr . IsIgnore = true ;
@@ -128,6 +123,17 @@ internal static TableInfo GetTableByEntity(Type entity, CommonUtils common) {
128123 trytb . ColumnsByCsIgnore . Add ( p . Name , col ) ;
129124 continue ;
130125 }
126+ colattr . DbDefautValue = trytb . Properties [ p . Name ] . GetValue ( Activator . CreateInstance ( trytb . Type ) ) ;
127+ if ( colattr . DbDefautValue != null && p . PropertyType != colattr . MapType ) colattr . DbDefautValue = Utils . GetDataReaderValue ( colattr . MapType , colattr . DbDefautValue ) ;
128+ if ( colattr . DbDefautValue == null ) colattr . DbDefautValue = tp ? . defaultValue ;
129+ if ( colattr . IsNullable == false && colattr . DbDefautValue == null ) {
130+ var citype = colattr . MapType . IsNullableType ( ) ? colattr . MapType . GenericTypeArguments . FirstOrDefault ( ) : colattr . MapType ;
131+ if ( citype . IsArray )
132+ colattr . DbDefautValue = Array . CreateInstance ( citype , 0 ) ;
133+ else
134+ colattr . DbDefautValue = Activator . CreateInstance ( citype ) ;
135+ }
136+
131137 trytb . Columns . Add ( colattr . Name , col ) ;
132138 trytb . ColumnsByCs . Add ( p . Name , col ) ;
133139 }
0 commit comments