@@ -21,19 +21,22 @@ protected override void SetSchema(MockSchemaProvider schemaProvider)
2121 new [ ] { "dbo" , "Employee" , "DepartmentId" } ,
2222 new [ ] { "dbo" , "Department" , "Id" } ,
2323 new [ ] { "dbo" , "Department" , "Name" } ,
24- new [ ] { "dbo" , "Activity" , "ID_Activity" } ,
25- new [ ] { "dbo" , "Activity" , "ID_Trip" } ,
26- new [ ] { "dbo" , "Activity" , "Activity_Time" } ,
27- new [ ] { "dbo" , "Activity" , "Is_Public" } ,
24+ new [ ] { "dbo" , "Activity" , "ID" } ,
25+ new [ ] { "dbo" , "Activity" , "Description" } ,
2826 new [ ] { "dbo" , "Activity_Join" , "ID_Activity" } ,
2927 new [ ] { "dbo" , "Activity_Join" , "ID_Location" } ,
30- new [ ] { "dbo" , "Location" , "ID_Location" }
28+ new [ ] { "dbo" , "Location" , "ID" } ,
29+ new [ ] { "dbo" , "Location" , "Address" }
3130 ) ;
3231
3332 schemaProvider . SetPrimaryKeys ( new object [ ] { "dbo" , "Employee" , "Id" , 0 } ,
3433 new object [ ] { "dbo" , "Department" , "Id" , 0 } ) ;
3534
36- schemaProvider . SetForeignKeys ( new object [ ] { "FK_Employee_Department" , "dbo" , "Employee" , "DepartmentId" , "dbo" , "Department" , "Id" , 0 } ) ;
35+ schemaProvider . SetForeignKeys (
36+ new object [ ] { "FK_Employee_Department" , "dbo" , "Employee" , "DepartmentId" , "dbo" , "Department" , "Id" , 0 } ,
37+ new object [ ] { "FK_Activity_Join_Activity" , "dbo" , "Activity_Join" , "ID_Activity" , "dbo" , "Activity" , "ID" , 0 } ,
38+ new object [ ] { "FK_Activity_Join_Location" , "dbo" , "Activity_Join" , "ID_Location" , "dbo" , "Location" , "ID" , 0 }
39+ ) ;
3740 }
3841
3942 [ Test ]
@@ -113,6 +116,25 @@ public void SingleWithClauseUsingReferenceWithAliasShouldApplyAliasToSql()
113116 GeneratedSqlIs ( expectedSql ) ;
114117 }
115118
119+ [ Test ]
120+ public void SingleWithClauseUsingTwoStepReference ( )
121+ {
122+ const string expectedSql = "select " +
123+ "[dbo].[activity].[id]," +
124+ "[dbo].[activity].[description]," +
125+ "[dbo].[location].[id] as [__withn__location__id]," +
126+ "[dbo].[location].[address] as [__withn__location__address]" +
127+ " from [dbo].[activity] " +
128+ "left join [dbo].[activity_join] on ([dbo].[activity].[id] = [dbo].[activity_join].[id_activity]) " +
129+ "left join [dbo].[location] on ([dbo].[location].[id] = [dbo].[activity_join].[id_location])" ;
130+
131+ var q = _db . Activity . All ( ) . With ( _db . Activity . ActivityJoin . Location ) ;
132+
133+ EatException ( ( ) => q . ToList ( ) ) ;
134+
135+ GeneratedSqlIs ( expectedSql ) ;
136+ }
137+
116138 [ Test ]
117139 public void SingleWithClauseUsingExplicitJoinShouldApplyAliasToSql ( )
118140 {
0 commit comments