@@ -9,7 +9,46 @@ public class WithTest : DatabaseIntegrationContext
99 {
1010 protected override void SetSchema ( MockSchemaProvider schemaProvider )
1111 {
12- throw new NotImplementedException ( ) ;
12+ schemaProvider . SetTables ( new [ ] { "dbo" , "Employee" , "BASE TABLE" } ,
13+ new [ ] { "dbo" , "Department" , "BASE TABLE" } ,
14+ new [ ] { "dbo" , "Activity" , "BASE TABLE" } ,
15+ new [ ] { "dbo" , "Activity_Join" , "BASE TABLE" } ,
16+ new [ ] { "dbo" , "Location" , "BASE_TABLE" } ) ;
17+
18+ schemaProvider . SetColumns ( new [ ] { "dbo" , "Employee" , "Id" } ,
19+ new [ ] { "dbo" , "Employee" , "Name" } ,
20+ new [ ] { "dbo" , "Employee" , "ManagerId" } ,
21+ new [ ] { "dbo" , "Employee" , "DepartmentId" } ,
22+ new [ ] { "dbo" , "Department" , "Id" } ,
23+ 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" } ,
28+ new [ ] { "dbo" , "Activity_Join" , "ID_Activity" } ,
29+ new [ ] { "dbo" , "Activity_Join" , "ID_Location" } ,
30+ new [ ] { "dbo" , "Location" , "ID_Location" }
31+ ) ;
32+ schemaProvider . SetPrimaryKeys (
33+ new object [ ] { "dbo" , "Employee" , "Id" , 0 } ,
34+ new object [ ] { "dbo" , "Department" , "Id" , 0 }
35+ ) ;
36+ schemaProvider . SetForeignKeys ( new object [ ] { "FK_Employee_Department" , "dbo" , "Employee" , "DepartmentId" , "dbo" , "Department" , "Id" , 0 } ) ;
37+ }
38+
39+ [ Test ]
40+ public void SingleWithClauseShouldUseJoin ( )
41+ {
42+ const string expectedSql = "select [employee].[id] as [__with__employee__id],[employee].[name] as [__with__employee__name]," +
43+ "[employee].[managerid] as [__with__employee__managerid],[employee].[departmentid] as [__with__employee__departmentid]," +
44+ "[department].[id] as [__with__department__id],[department].[name] as [__with__department__name]" +
45+ "from [employee] left join [department] on [employee].[departmentid] = [department].[id]" ;
46+
47+ var q = _db . Employees . All ( ) . WithDepartment ( ) ;
48+
49+ EatException ( ( ) => q . ToList ( ) ) ;
50+
51+ GeneratedSqlIs ( expectedSql ) ;
1352 }
1453 }
1554}
0 commit comments