public async Task PersistAsync(ICollection <string> entities) { var batch = new TableBatchOperation(); foreach (var url in entities) { var rowKey = GetRowKey(url); var row = await _table.ExecuteAsync(TableOperation.Retrieve(PartitionKey, rowKey, new List <string>())); if (row.Result == null) { var persistedEntity = new PersistedEntity { PartitionKey = PartitionKey, RowKey = rowKey, Url = url, Notified = false }; batch.InsertOrMerge(persistedEntity); } } if (batch.Any()) { await _table.ExecuteBatchAsync(batch); } }
public async Task MarkNotifiedAsync(ICollection <string> entities) { var batch = new TableBatchOperation(); foreach (var url in entities) { var persistedEntity = new PersistedEntity { PartitionKey = PartitionKey, RowKey = GetRowKey(url), Url = url, Notified = true }; batch.InsertOrMerge(persistedEntity); } if (batch.Any()) { await _table.ExecuteBatchAsync(batch); } }