@@ -1246,6 +1246,106 @@ public void get_record_with_calculated_partition_key_from_multiple_properties()
12461246
12471247 }
12481248
1249+ [ TestMethod ]
1250+ public void update_record_with_calculated_partition_key_from_multiple_properties ( )
1251+ {
1252+ tableStore = new PocoTableStore < Employee , int , int > ( "TestEmployee" , "UseDevelopmentStorage=true" ,
1253+ partitionProperty : null , rowProperty : e => e . Id , calculatedPartitionKey : e => e . CompanyId + "." + e . Department . Id , calculatedRowKey : e => e . Id . ToString ( ) ,
1254+ calculatedPartitionKeyFromParameter : x => null ,
1255+ calculatedRowKeyFromParameter : x => x . ToString ( ) ,
1256+ convertPartitionKey : null , convertRowKey : int . Parse ) ;
1257+
1258+ var employee = new Employee
1259+ {
1260+ CompanyId = 1 ,
1261+ Id = 1 ,
1262+ Name = "Mr. Jim CEO" ,
1263+ Department = new Department { Id = 22 , Name = "Executive" }
1264+ } ;
1265+ tableStore . Insert ( employee ) ;
1266+
1267+ employee . Name = "Ted" ;
1268+
1269+ tableStore . Update ( employee ) ;
1270+
1271+ var record = tableStore . GetRecord ( "1.22" , "1" ) ;
1272+
1273+ Assert . AreEqual ( 1 , record . Id ) ;
1274+ Assert . AreEqual ( 22 , record . Department . Id ) ;
1275+ Assert . AreEqual ( "Ted" , record . Name ) ;
1276+
1277+ }
1278+
1279+ [ TestMethod ]
1280+ public void get_record_with_calculated_partition_key_from_multiple_properties_using_extension_method ( )
1281+ {
1282+ KeyGenerator . DefineParitionKey ( typeof ( Employee ) , e=> $ "{ e . CompanyId } .{ e . DepartmentId } ") ;
1283+ KeyGenerator . DefineRowKey ( typeof ( Employee ) , e => $ "{ e . Id } ") ;
1284+
1285+ tableStore = new PocoTableStore < Employee , int , int > ( "TestEmployee" , "UseDevelopmentStorage=true" ,
1286+ partitionProperty : null , rowProperty : e => e . Id , calculatedPartitionKey : e => e . CompanyId + "." + e . Department . Id , calculatedRowKey : e => e . Id . ToString ( ) ,
1287+ calculatedPartitionKeyFromParameter : x => null ,
1288+ calculatedRowKeyFromParameter : x => x . ToString ( ) ,
1289+ convertPartitionKey : null , convertRowKey : int . Parse ) ;
1290+
1291+
1292+
1293+ var employee = new Employee
1294+ {
1295+ CompanyId = 1 ,
1296+ Id = 1 ,
1297+ Name = "Mr. Jim CEO" ,
1298+ Department = new Department { Id = 22 , Name = "Executive" }
1299+ } ;
1300+ tableStore . Insert ( employee ) ;
1301+
1302+ var record = tableStore . GetRecord ( KeyGenerator . PartitionKey < Employee > ( new { CompanyId = 1 , DepartmentId = 22 } ) ,
1303+ KeyGenerator . RowKey < Employee > ( new { Id = 1 } ) ) ;
1304+
1305+ Assert . AreEqual ( 1 , record . Id ) ;
1306+ Assert . AreEqual ( 22 , record . Department . Id ) ;
1307+ Assert . AreEqual ( "Mr. Jim CEO" , record . Name ) ;
1308+
1309+ }
1310+
1311+
1312+ [ TestMethod ]
1313+ public void update_record_with_calculated_partition_key_from_multiple_properties_using_extension_method ( )
1314+ {
1315+ KeyGenerator . DefineParitionKey ( typeof ( Employee ) , e => $ "{ e . CompanyId } .{ e . DepartmentId } ") ;
1316+ KeyGenerator . DefineRowKey ( typeof ( Employee ) , e => $ "{ e . Id } ") ;
1317+
1318+ tableStore = new PocoTableStore < Employee , int , int > ( "TestEmployee" , "UseDevelopmentStorage=true" ,
1319+ partitionProperty : null , rowProperty : e => e . Id , calculatedPartitionKey : e => e . CompanyId + "." + e . Department . Id , calculatedRowKey : e => e . Id . ToString ( ) ,
1320+ calculatedPartitionKeyFromParameter : x => null ,
1321+ calculatedRowKeyFromParameter : x => x . ToString ( ) ,
1322+ convertPartitionKey : null , convertRowKey : int . Parse ) ;
1323+
1324+
1325+
1326+ var employee = new Employee
1327+ {
1328+ CompanyId = 1 ,
1329+ Id = 1 ,
1330+ Name = "Mr. Jim CEO" ,
1331+ Department = new Department { Id = 22 , Name = "Executive" }
1332+ } ;
1333+ tableStore . Insert ( employee ) ;
1334+
1335+ employee . Name = "Ted" ;
1336+
1337+ tableStore . Update ( employee ) ;
1338+
1339+ var record = tableStore . GetRecord (
1340+ KeyGenerator . PartitionKey < Employee > ( new { CompanyId = 1 , DepartmentId = 22 } ) ,
1341+ KeyGenerator . RowKey < Employee > ( new { Id = 1 } ) ) ;
1342+
1343+ Assert . AreEqual ( 1 , record . Id ) ;
1344+ Assert . AreEqual ( 22 , record . Department . Id ) ;
1345+ Assert . AreEqual ( "Ted" , record . Name ) ;
1346+
1347+ }
1348+
12491349 [ TestCleanup ]
12501350 public void Cleanup ( )
12511351 {
0 commit comments