Am trying to delete Azure table entities based on my range filter. All am trying here is to delete the older records.
I was able to get the correct entites based on my range search condition.
TableQuery<Tables> rangeQuery = new TableQuery<Tables>().Where(
TableQuery.CombineFilters(
TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, "DeleteTablename"),
TableOperators.And,
TableQuery.GenerateFilterConditionForDate("StartedOn", QueryComparisons.LessThan, DateTime.Now.Add(new TimeSpan(0, -60, 0)))));
foreach(Tables rows in logTable.ExecuteQuery(rangeQuery)) {
log.Info($"{rows.PartitionKey}, {rows.RowKey}\t{rows.FinishedOn}\t{rows.Timestamp}");
}
//till here it works
TableResult retrievedResult = logTable.ExecuteQuery(rangeQuery);
Tables deleteEntity = (Tables)retrievedResult.Result;
am getting following errors
Cannot implicitly convert type 'System.Collections.Generic.IEnumerable' to 'Microsoft.WindowsAzure.Storage.Table.TableResult' timertest
Cannot convert type 'Microsoft.WindowsAzure.Storage.Table.TableResult' to 'timertest.Tables' timertest
Notes:
timertest
is my namespace
Tables
is a class, that extends TableEntity
class to add my
custom proporties in azure table.Any ideas to delete entities based on range ?
Any ideas to delete entities based on range?
In Azure Tables to perform bulk delete, you will need to use Entity Group Transaction
and add the entities that you wish to delete in a batch and then execute that batch operation. For entities to be manipulated (create, update or delete) in a batch:
PartitionKey
value.Please note that even if one entity fails in the group transaction, the entire transaction is rolled back.
You can learn more about entity batch transaction here: https://learn.microsoft.com/en-us/rest/api/storageservices/performing-entity-group-transactions.