11using System ;
22using System . Collections . Generic ;
3+ using System . Diagnostics ;
34using System . Linq ;
45using System . Text ;
56
@@ -14,14 +15,25 @@ public class ExplicitJoinTest : DatabaseIntegrationContext
1415 protected override void SetSchema ( MockSchemaProvider schemaProvider )
1516 {
1617 schemaProvider . SetTables ( new [ ] { "dbo" , "Employee" , "BASE TABLE" } ,
17- new [ ] { "dbo" , "Department" , "BASE TABLE" } ) ;
18+ new [ ] { "dbo" , "Department" , "BASE TABLE" } ,
19+ new [ ] { "dbo" , "Activity" , "BASE TABLE" } ,
20+ new [ ] { "dbo" , "Activity_Join" , "BASE TABLE" } ,
21+ new [ ] { "dbo" , "Location" , "BASE_TABLE" } ) ;
1822
1923 schemaProvider . SetColumns ( new [ ] { "dbo" , "Employee" , "Id" } ,
2024 new [ ] { "dbo" , "Employee" , "Name" } ,
2125 new [ ] { "dbo" , "Employee" , "ManagerId" } ,
2226 new [ ] { "dbo" , "Employee" , "DepartmentId" } ,
2327 new [ ] { "dbo" , "Department" , "Id" } ,
24- new [ ] { "dbo" , "Department" , "Name" } ) ;
28+ new [ ] { "dbo" , "Department" , "Name" } ,
29+ new [ ] { "dbo" , "Activity" , "ID_Activity" } ,
30+ new [ ] { "dbo" , "Activity" , "ID_Trip" } ,
31+ new [ ] { "dbo" , "Activity" , "Activity_Time" } ,
32+ new [ ] { "dbo" , "Activity" , "Is_Public" } ,
33+ new [ ] { "dbo" , "Activity_Join" , "ID_Activity" } ,
34+ new [ ] { "dbo" , "Activity_Join" , "ID_Location" } ,
35+ new [ ] { "dbo" , "Location" , "ID_Location" }
36+ ) ;
2537 }
2638
2739 [ Test ]
@@ -139,5 +151,32 @@ public void SelfJoinWithExplicitClauseUsingExpressionAndOutParameter()
139151 GeneratedSqlIs ( "select [dbo].[employee].[name],[manager].[name] as [Manager] from [dbo].[employee]" +
140152 " join [dbo].[employee] [manager] on ([manager].[id] = [dbo].[employee].[managerid])" ) ;
141153 }
154+
155+ [ Test ]
156+ public void TwoJoins ( )
157+ {
158+ _db . Activity . Query ( )
159+ . Join ( _db . Activity_Join ) . On ( _db . Activity . ID_Activity == _db . Activity_Join . ID_Activity )
160+ . Join ( _db . Location ) . On ( _db . Activity_Join . ID_Location == _db . Location . ID_Location )
161+ . Where ( _db . Activity . ID_trip == 1 &&
162+ _db . Activity . Activity_Time == 'D' &&
163+ _db . Activity . Is_Public == true )
164+ . Select (
165+ _db . Activity . ID_Activity
166+ , _db . Activity . ID_Trip
167+ , _db . Activity . Activity_Time
168+ , _db . Activity . Is_Public )
169+ . ToList < Activity > ( ) ;
170+
171+ GeneratedSqlIs ( "select [dbo].[Activity].[ID_Activity],[dbo].[Activity].[ID_Trip],[dbo].[Activity].[Activity_Time],[dbo].[Activity].[Is_Public] " +
172+ "from [dbo].[Activity] JOIN [dbo].[Activity_Join] ON ([dbo].[Activity].[ID_Activity] = [dbo].[Activity_Join].[ID_Activity]) " +
173+ "JOIN [dbo].[Location] ON ([dbo].[Activity_Join].[ID_Location] = [dbo].[Location].[ID_Location]) " +
174+ "WHERE (([dbo].[Activity].[ID_Trip] = @p1 AND [dbo].[Activity].[Activity_Time] = @p2) AND [dbo].[Activity].[Is_Public] = @p3)" ) ;
175+ }
176+
177+ class Activity
178+ {
179+ public int ID_Activity { get ; set ; }
180+ }
142181 }
143182}
0 commit comments