@@ -13,6 +13,8 @@ protected override void SetSchema(MockSchemaProvider schemaProvider)
1313 {
1414 schemaProvider . SetTables ( new [ ] { "dbo" , "Users" , "BASE TABLE" } ,
1515 new [ ] { "dbo" , "UserHistory" , "BASE TABLE" } ,
16+ new [ ] { "dbo" , "AnnoyingMaster" , "BASE TABLE" } ,
17+ new [ ] { "dbo" , "AnnoyingDetail" , "BASE TABLE" } ,
1618 new [ ] { "dbo" , "USER_TABLE" , "BASE TABLE" } ) ;
1719
1820 schemaProvider . SetColumns ( new object [ ] { "dbo" , "Users" , "Id" , true } ,
@@ -22,16 +24,30 @@ protected override void SetSchema(MockSchemaProvider schemaProvider)
2224 new [ ] { "dbo" , "UserHistory" , "Id" } ,
2325 new [ ] { "dbo" , "UserHistory" , "UserId" } ,
2426 new [ ] { "dbo" , "UserHistory" , "LastSeen" } ,
27+ new [ ] { "dbo" , "AnnoyingMaster" , "Id1" } ,
28+ new [ ] { "dbo" , "AnnoyingMaster" , "Id2" } ,
29+ new [ ] { "dbo" , "AnnoyingMaster" , "Text" } ,
30+ new [ ] { "dbo" , "AnnoyingDetail" , "Id" } ,
31+ new [ ] { "dbo" , "AnnoyingDetail" , "MasterId1" } ,
32+ new [ ] { "dbo" , "AnnoyingDetail" , "MasterId2" } ,
33+ new [ ] { "dbo" , "AnnoyingDetail" , "Value" } ,
2534 new object [ ] { "dbo" , "USER_TABLE" , "ID" , true } ,
2635 new [ ] { "dbo" , "USER_TABLE" , "NAME" } ,
2736 new [ ] { "dbo" , "USER_TABLE" , "PASSWORD" } ,
2837 new [ ] { "dbo" , "USER_TABLE" , "AGE" } ) ;
2938
3039 schemaProvider . SetPrimaryKeys ( new object [ ] { "dbo" , "Users" , "Id" , 0 } ,
3140 new object [ ] { "dbo" , "UserHistory" , "Id" , 0 } ,
41+ new object [ ] { "dbo" , "AnnoyingMaster" , "Id1" , 0 } ,
42+ new object [ ] { "dbo" , "AnnoyingMaster" , "Id2" , 1 } ,
43+ new object [ ] { "dbo" , "AnnoyingDetail" , "Id" , 0 } ,
3244 new object [ ] { "dbo" , "USER_TABLE" , "ID" , 0 } ) ;
3345
34- schemaProvider . SetForeignKeys ( new object [ ] { "FK_UserHistory_User" , "dbo" , "UserHistory" , "UserId" , "dbo" , "Users" , "Id" , 0 } ) ;
46+ schemaProvider . SetForeignKeys (
47+ new object [ ] { "FK_UserHistory_User" , "dbo" , "UserHistory" , "UserId" , "dbo" , "Users" , "Id" , 0 } ,
48+ new object [ ] { "FK_AnnoyingDetail_AnnoyingMaster" , "dbo" , "AnnoyingDetail" , "MasterId1" , "dbo" , "AnnoyingMaster" , "Id1" , 0 } ,
49+ new object [ ] { "FK_AnnoyingDetail_AnnoyingMaster" , "dbo" , "AnnoyingDetail" , "MasterId2" , "dbo" , "AnnoyingMaster" , "Id2" , 1 }
50+ ) ;
3551 }
3652
3753 [ Test ]
@@ -321,6 +337,17 @@ public void TestUpdateWithCriteriaWithNaturalJoin()
321337 Parameter ( 1 ) . Is ( yearAgo ) ;
322338 }
323339
340+ [ Test ]
341+ public void TestUpdateWithCriteriaWithNaturalJoinOnCompoundKeyTable ( )
342+ {
343+ _db . AnnoyingMaster . UpdateAll ( _db . AnnoyingMaster . AnnoyingDetail . Value < 42 , Text : "Really annoying" ) ;
344+ GeneratedSqlIs ( "update [dbo].[AnnoyingMaster] set [Text] = @p1 where exists " +
345+ "(select 1 from [dbo].[AnnoyingMaster] [_updatejoin] join [dbo].[AnnoyingDetail] on ([_updatejoin].[Id1] = [dbo].[AnnoyingDetail].[MasterId1] and [_updatejoin].[Id2] = [dbo].[AnnoyingDetail].[MasterId2]) " +
346+ "where [dbo].[AnnoyingDetail].[Value] < @p2 and ([_updatejoin].[Id1] = [dbo].[AnnoyingMaster].[Id1] and [_updatejoin].[Id2] = [dbo].[AnnoyingMaster].[Id2]))" ) ;
347+ Parameter ( 0 ) . Is ( "Really annoying" ) ;
348+ Parameter ( 1 ) . Is ( 42 ) ;
349+ }
350+
324351 [ Test ]
325352 public void TestUpdateWithCriteriaAndDictionary ( )
326353 {
0 commit comments