@@ -460,13 +460,14 @@ public IUpdate<T1> ToUpdate()
460460 protected List < Dictionary < Type , string > > GetTableRuleUnions ( )
461461 {
462462 var unions = new List < Dictionary < Type , string > > ( ) ;
463- var trs = _tableRules . Any ( ) ? _tableRules : new List < Func < Type , string , string > > ( ) ;
463+ var trs = _tableRules . Any ( ) ? _tableRules : new List < Func < Type , string , string > > ( new [ ] { new Func < Type , string , string > ( ( type , oldname ) => null ) } ) ;
464464
465- if ( trs . Any ( ) == false )
465+ if ( trs . Count == 1 && _tables . Any ( a => a . Table . AsTableImpl != null && string . IsNullOrWhiteSpace ( trs [ 0 ] ( a . Table . Type , a . Table . DbName ) ) == true ) )
466466 {
467467 string [ ] LocalGetTableNames ( SelectTableInfo tb )
468468 {
469- if ( tb . Table . AsTableImpl != null )
469+ var trname = trs [ 0 ] ( tb . Table . Type , tb . Table . DbName ) ;
470+ if ( tb . Table . AsTableImpl != null && string . IsNullOrWhiteSpace ( trname ) == true )
470471 {
471472 string [ ] aret = null ;
472473 if ( _where . Length == 0 ) aret = tb . Table . AsTableImpl . AllTables ;
@@ -481,6 +482,18 @@ string[] LocalGetTableNames(SelectTableInfo tb)
481482 }
482483 return aret ;
483484 }
485+ if ( string . IsNullOrWhiteSpace ( trname ) == false )
486+ {
487+ if ( trname . IndexOf ( ' ' ) == - 1 ) //还可以这样:select.AsTable((a, b) => "(select * from tb_topic where clicks > 10)").Page(1, 10).ToList()
488+ {
489+ if ( _orm . CodeFirst . IsSyncStructureToLower ) trname = trname . ToLower ( ) ;
490+ if ( _orm . CodeFirst . IsSyncStructureToUpper ) trname = trname . ToUpper ( ) ;
491+ if ( _orm . CodeFirst . IsAutoSyncStructure ) _orm . CodeFirst . SyncStructure ( tb . Table . Type , trname ) ;
492+ }
493+ else
494+ trname = trname . Replace ( " \r \n " , " \r \n " ) ;
495+ return new string [ ] { trname } ;
496+ }
484497 return new string [ ] { tb . Table . DbName } ;
485498 }
486499 var tbnames = _tables . GroupBy ( a => a . Table . Type ) . Select ( g => _tables . Where ( a => a . Table . Type == g . Key ) . FirstOrDefault ( ) ) . Select ( a => new { Tb = a , Names = LocalGetTableNames ( a ) } ) . ToList ( ) ;
0 commit comments