@@ -9,7 +9,7 @@ namespace TableStorage.Abstractions.POCO.SecondaryIndexes
99{
1010 public static class PocoStoreIndexer
1111 {
12- private static readonly Dictionary < string , object > _indexes = new Dictionary < string , object > ( ) ;
12+ private static readonly Dictionary < string , dynamic > _indexes = new Dictionary < string , dynamic > ( ) ;
1313
1414 private static object _indexLock = new object ( ) ;
1515
@@ -33,7 +33,6 @@ public static void AddIndex<T, TPartitionKey, TRowKey, TIndexPartitionKey, TInde
3333 {
3434 throw new ArgumentException ( $ "{ indexName } has already been added") ;
3535 }
36-
3736 _indexes [ indexName ] = indexStore ;
3837 tableStore . OnRecordInsertedOrUpdated += indexStore . InsertOrReplace ;
3938 tableStore . OnRecordInsertedOrUpdatedAsync += indexStore . InsertOrReplaceAsync ;
@@ -459,18 +458,19 @@ public static async Task ReindexAsync<T, TPartitionKey, TRowKey>(this IPocoTable
459458 {
460459 try
461460 {
462- dynamic indexStore = _indexes [ indexName ] ;
461+ var indexStore = _indexes [ indexName ] ;
463462 do
464463 {
465- var result = await indexStore . GetAllRecordsPagedAsync ( 1000 , pageToken ) ;
464+ var result = await tableStore . GetAllRecordsPagedAsync ( 1000 , pageToken ) ;
466465 pageToken = result . ContinuationToken ;
467-
466+ var insertOrReplaceAsync = indexStore . GetType ( ) . GetMethod ( "InsertOrReplaceAsync" ) ;
468467 if ( result . Items . Count > 0 )
469468 {
470469 foreach ( var record in result . Items )
471470 {
472471 await semaphore . WaitAsync ( TimeSpan . FromSeconds ( 20 ) ) ;
473- Task task = indexStore . InsertOrReplaceAsync ( record ) ;
472+ //Task task = indexStore.InsertOrReplaceAsync(record); //this line worked in the unit tests but not in a console app. Not sure why.
473+ var task = ( Task ) insertOrReplaceAsync . Invoke ( indexStore , new object [ ] { record } ) ;
474474 task . ContinueWith ( r =>
475475 {
476476 if ( r . IsFaulted )
0 commit comments