@@ -58,31 +58,74 @@ internal TableAttribute GetConfigEntity(Type type) {
5858 return dicConfigEntity . TryGetValue ( type , out var trytb ) ? trytb : null ;
5959 }
6060 internal TableAttribute GetEntityTableAttribute ( Type type ) {
61- var attr = type . GetCustomAttributes ( typeof ( TableAttribute ) , false ) . LastOrDefault ( ) as TableAttribute ;
62- if ( dicConfigEntity . TryGetValue ( type , out var trytb ) == false ) return attr ;
61+ TableAttribute attr = null ;
62+ if ( _orm . Aop . ConfigEntity != null ) {
63+ var aope = new AopConfigEntityEventArgs ( type ) ;
64+ _orm . Aop . ConfigEntity ( _orm , aope ) ;
65+ attr = aope . ModifyResult ;
66+ }
6367 if ( attr == null ) attr = new TableAttribute ( ) ;
64-
65- if ( string . IsNullOrEmpty ( attr . Name ) ) attr . Name = trytb . Name ;
66- if ( string . IsNullOrEmpty ( attr . OldName ) ) attr . OldName = trytb . OldName ;
67- if ( string . IsNullOrEmpty ( attr . SelectFilter ) ) attr . SelectFilter = trytb . SelectFilter ;
68- return attr ;
68+ if ( dicConfigEntity . TryGetValue ( type , out var trytb ) ) {
69+ if ( ! string . IsNullOrEmpty ( trytb . Name ) ) attr . Name = trytb . Name ;
70+ if ( ! string . IsNullOrEmpty ( trytb . OldName ) ) attr . OldName = trytb . OldName ;
71+ if ( ! string . IsNullOrEmpty ( trytb . SelectFilter ) ) attr . SelectFilter = trytb . SelectFilter ;
72+ }
73+ var attrs = type . GetCustomAttributes ( typeof ( TableAttribute ) , false ) ;
74+ foreach ( var tryattrobj in attrs ) {
75+ var tryattr = tryattrobj as TableAttribute ;
76+ if ( tryattr == null ) continue ;
77+ if ( ! string . IsNullOrEmpty ( tryattr . Name ) ) attr . Name = tryattr . Name ;
78+ if ( ! string . IsNullOrEmpty ( tryattr . OldName ) ) attr . OldName = tryattr . OldName ;
79+ if ( ! string . IsNullOrEmpty ( tryattr . SelectFilter ) ) attr . SelectFilter = tryattr . SelectFilter ;
80+ }
81+ if ( ! string . IsNullOrEmpty ( attr . Name ) ) return attr ;
82+ if ( ! string . IsNullOrEmpty ( attr . OldName ) ) return attr ;
83+ if ( ! string . IsNullOrEmpty ( attr . SelectFilter ) ) return attr ;
84+ return null ;
6985 }
7086 internal ColumnAttribute GetEntityColumnAttribute ( Type type , PropertyInfo proto ) {
71- var attr = proto . GetCustomAttributes ( typeof ( ColumnAttribute ) , false ) . LastOrDefault ( ) as ColumnAttribute ;
72- if ( dicConfigEntity . TryGetValue ( type , out var trytb ) == false ) return attr ;
73- if ( trytb . _columns . TryGetValue ( proto . Name , out var trycol ) == false ) return attr ;
87+ ColumnAttribute attr = null ;
88+ if ( _orm . Aop . ConfigEntityProperty != null ) {
89+ var aope = new AopConfigEntityPropertyEventArgs ( type , proto ) ;
90+ _orm . Aop . ConfigEntityProperty ( _orm , aope ) ;
91+ attr = aope . ModifyResult ;
92+ }
7493 if ( attr == null ) attr = new ColumnAttribute ( ) ;
75-
76- if ( string . IsNullOrEmpty ( attr . Name ) ) attr . Name = trycol . Name ;
77- if ( string . IsNullOrEmpty ( attr . OldName ) ) attr . OldName = trycol . OldName ;
78- if ( string . IsNullOrEmpty ( attr . DbType ) ) attr . DbType = trycol . DbType ;
79- if ( attr . _IsPrimary == null ) attr . _IsPrimary = trycol . IsPrimary ;
80- if ( attr . _IsIdentity == null ) attr . _IsIdentity = trycol . IsIdentity ;
81- if ( attr . _IsNullable == null ) attr . _IsNullable = trycol . IsNullable ;
82- if ( attr . _IsIgnore == null ) attr . _IsIgnore = trycol . IsIgnore ;
83- if ( attr . _IsVersion == null ) attr . _IsVersion = trycol . IsVersion ;
84- if ( attr . DbDefautValue == null ) attr . DbDefautValue = trycol . DbDefautValue ;
85- return attr ;
94+ if ( dicConfigEntity . TryGetValue ( type , out var trytb ) && trytb . _columns . TryGetValue ( proto . Name , out var trycol ) ) {
95+ if ( ! string . IsNullOrEmpty ( trycol . Name ) ) attr . Name = trycol . Name ;
96+ if ( ! string . IsNullOrEmpty ( trycol . OldName ) ) attr . OldName = trycol . OldName ;
97+ if ( ! string . IsNullOrEmpty ( trycol . DbType ) ) attr . DbType = trycol . DbType ;
98+ if ( trycol . _IsPrimary != null ) attr . _IsPrimary = trycol . IsPrimary ;
99+ if ( trycol . _IsIdentity != null ) attr . _IsIdentity = trycol . IsIdentity ;
100+ if ( trycol . _IsNullable != null ) attr . _IsNullable = trycol . IsNullable ;
101+ if ( trycol . _IsIgnore != null ) attr . _IsIgnore = trycol . IsIgnore ;
102+ if ( trycol . _IsVersion != null ) attr . _IsVersion = trycol . IsVersion ;
103+ if ( trycol . DbDefautValue != null ) attr . DbDefautValue = trycol . DbDefautValue ;
104+ }
105+ var attrs = proto . GetCustomAttributes ( typeof ( ColumnAttribute ) , false ) ;
106+ foreach ( var tryattrobj in attrs ) {
107+ var tryattr = tryattrobj as ColumnAttribute ;
108+ if ( tryattr == null ) continue ;
109+ if ( ! string . IsNullOrEmpty ( tryattr . Name ) ) attr . Name = tryattr . Name ;
110+ if ( ! string . IsNullOrEmpty ( tryattr . OldName ) ) attr . OldName = tryattr . OldName ;
111+ if ( ! string . IsNullOrEmpty ( tryattr . DbType ) ) attr . DbType = tryattr . DbType ;
112+ if ( tryattr . _IsPrimary != null ) attr . _IsPrimary = tryattr . IsPrimary ;
113+ if ( tryattr . _IsIdentity != null ) attr . _IsIdentity = tryattr . IsIdentity ;
114+ if ( tryattr . _IsNullable != null ) attr . _IsNullable = tryattr . IsNullable ;
115+ if ( tryattr . _IsIgnore != null ) attr . _IsIgnore = tryattr . IsIgnore ;
116+ if ( tryattr . _IsVersion != null ) attr . _IsVersion = tryattr . IsVersion ;
117+ if ( tryattr . DbDefautValue != null ) attr . DbDefautValue = tryattr . DbDefautValue ;
118+ }
119+ if ( ! string . IsNullOrEmpty ( attr . Name ) ) return attr ;
120+ if ( ! string . IsNullOrEmpty ( attr . OldName ) ) return attr ;
121+ if ( ! string . IsNullOrEmpty ( attr . DbType ) ) return attr ;
122+ if ( attr . _IsPrimary != null ) return attr ;
123+ if ( attr . _IsIdentity != null ) return attr ;
124+ if ( attr . _IsNullable != null ) return attr ;
125+ if ( attr . _IsIgnore != null ) return attr ;
126+ if ( attr . _IsVersion != null ) return attr ;
127+ if ( attr . DbDefautValue != null ) return attr ;
128+ return null ;
86129 }
87130
88131 internal string WhereObject ( TableInfo table , string aliasAndDot , object dywhere ) {
0 commit comments