Skip to content

Commit 61d40af

Browse files
committed
fix delete bug
1 parent 4cca48e commit 61d40af

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

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

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.Collections.Generic;
33
using System.Threading;
44
using System.Threading.Tasks;
5+
using Microsoft.Azure.Cosmos.Table;
56
using Microsoft.Azure.Documents;
67
using TableStorage.Abstractions.Models;
78

@@ -38,8 +39,29 @@ public static void AddIndex<T, TPartitionKey, TRowKey, TIndexPartitionKey, TInde
3839
tableStore.OnRecordInsertedOrUpdatedAsync += indexStore.InsertOrReplaceAsync;
3940
tableStore.OnRecordsInserted += indexStore.Insert;
4041
tableStore.OnRecordsInsertedAsync += indexStore.InsertAsync;
41-
tableStore.OnRecordDeleted += indexStore.Delete;
42-
tableStore.OnRecordDeletedAsync += indexStore.DeleteAsync;
42+
tableStore.OnRecordDeleted += obj =>
43+
{
44+
try
45+
{
46+
indexStore.Delete(obj);
47+
}
48+
catch (StorageException e) when (e.Message == "Not Found")
49+
{
50+
// if the index row wasn't there there is nothing to do
51+
}
52+
};
53+
tableStore.OnRecordDeletedAsync += async obj =>
54+
{
55+
try
56+
{
57+
await indexStore.DeleteAsync(obj);
58+
}
59+
catch (StorageException e) when (e.Message == "Not Found")
60+
{
61+
// if the index row wasn't there there is nothing to do
62+
}
63+
64+
};
4365
tableStore.OnTableDeleted += (name, table) =>
4466
{
4567
lock (_indexLock)

0 commit comments

Comments
 (0)