Skip to content

Commit 1e4bc35

Browse files
committed
bug fix
1 parent 158eb8d commit 1e4bc35

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/TableStorage.Abstractions.POCO.SecondaryIndexes/PocoStoreIndexer.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -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)

src/TableStorage.Abstractions.POCO.sln

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TableStorage.Abstractions.P
99
EndProject
1010
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TableStorage.Abstractions.POCO.SecondaryIndexes.Tests", "..\tests\TableStorage.Abstractions.POCO.SecondaryIndexes.Tests\TableStorage.Abstractions.POCO.SecondaryIndexes.Tests.csproj", "{FE11BC63-55E3-4D56-B730-98CF5EF9D03F}"
1111
EndProject
12-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TableStorage.Abstractions.POCO.Tests", "..\tests\TableStorage.Abstractions.POCO.Tests\TableStorage.Abstractions.POCO.Tests.csproj", "{005D8280-599C-4952-BBAB-EDAF51BFF70F}"
12+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TableStorage.Abstractions.POCO.Tests", "..\tests\TableStorage.Abstractions.POCO.Tests\TableStorage.Abstractions.POCO.Tests.csproj", "{005D8280-599C-4952-BBAB-EDAF51BFF70F}"
1313
EndProject
1414
Global
1515
GlobalSection(SolutionConfigurationPlatforms) = preSolution

0 commit comments

Comments
 (0)