44using ServiceStack . DataAnnotations ;
55using ServiceStack . Model ;
66using ServiceStack . OrmLite . Tests . UseCase ;
7+ using ServiceStack . Text ;
78
89namespace ServiceStack . OrmLite . Tests
910{
@@ -556,6 +557,7 @@ public void Can_join_on_references_attribute()
556557 db . DropTable < TABLE_2 > ( ) ;
557558 db . DropAndCreateTable < TABLE_1 > ( ) ;
558559 db . DropAndCreateTable < TABLE_2 > ( ) ;
560+ db . DropAndCreateTable < TABLE_3 > ( ) ;
559561
560562 var id1 = db . Insert ( new TABLE_1 { One = "A" } , selectIdentity : true ) ;
561563 var id2 = db . Insert ( new TABLE_1 { One = "B" } , selectIdentity : true ) ;
@@ -568,10 +570,17 @@ public void Can_join_on_references_attribute()
568570
569571 Assert . That ( results . Count , Is . EqualTo ( 1 ) ) ;
570572 Assert . That ( results [ 0 ] . One , Is . EqualTo ( "A" ) ) ;
573+
574+ var row3 = new TABLE_3 { TableTwo = new TABLE_2 { Three = "3" } } ;
575+ db . Save ( row3 ) ;
576+ Assert . That ( row3 . TableTwoKey , Is . EqualTo ( row3 . TableTwo . Id ) ) ;
577+
578+ row3 = db . SingleById < TABLE_3 > ( row3 . Id ) ;
579+ Assert . That ( row3 . TableTwoKey , Is . EqualTo ( row3 . TableTwo . Id ) ) ;
571580 }
572581 }
573582
574- [ Alias ( "Tabela1 " ) ]
583+ [ Alias ( "Table1 " ) ]
575584 public class TABLE_1 : IHasId < int >
576585 {
577586 [ AutoIncrement ]
@@ -582,7 +591,7 @@ public class TABLE_1 : IHasId<int>
582591 public string One { get ; set ; }
583592 }
584593
585- [ Alias ( "Tabela2 " ) ]
594+ [ Alias ( "Table2 " ) ]
586595 public class TABLE_2 : IHasId < int >
587596 {
588597 [ AutoIncrement ]
@@ -593,7 +602,23 @@ public class TABLE_2 : IHasId<int>
593602 public string Three { get ; set ; }
594603
595604 [ References ( typeof ( TABLE_1 ) ) ]
596- [ Alias ( "Tabela1 " ) ]
605+ [ Alias ( "Table1 " ) ]
597606 public int TableOneKey { get ; set ; }
598607 }
608+
609+ [ Alias ( "Table3" ) ]
610+ public class TABLE_3 : IHasId < int >
611+ {
612+ [ AutoIncrement ]
613+ [ Alias ( "Key" ) ]
614+ public int Id { get ; set ; }
615+
616+ [ Alias ( "Tri" ) ]
617+ public string Three { get ; set ; }
618+
619+ [ References ( typeof ( TABLE_2 ) ) ]
620+ public int TableTwoKey { get ; set ; }
621+
622+ public TABLE_2 TableTwo { get ; set ; }
623+ }
599624}
0 commit comments