private async Task WriteIndexDefinitionsToTableAsync(SaveType batchOperation) { // Iterate through the index definitions and save all the cloud table entities that are in each index -- This was built up // from other methods that came from a call to save the entities for (var i = 0; i < IndexDefinitions.Count; i++) { var indexDefinition = IndexDefinitions[i]; if (indexDefinition.CloudTableEntities.Count > 0) { var entitiesArray = indexDefinition.CloudTableEntities.ToArray(); switch (batchOperation) { case SaveType.InsertOrReplace: await TableOperationsService.InsertOrReplaceAsync(entitiesArray).ConfigureAwait(false); break; case SaveType.InsertOrMerge: // Even if the client calls for a merge we need to replace since the whole object is being serialized anyways. await TableOperationsService.InsertOrReplaceAsync(entitiesArray).ConfigureAwait(false); break; case SaveType.Insert: await TableOperationsService.InsertAsync(entitiesArray).ConfigureAwait(false); break; case SaveType.Replace: await TableOperationsService.ReplaceAsync(entitiesArray).ConfigureAwait(false); break; case SaveType.Delete: await TableOperationsService.DeleteAsync(entitiesArray).ConfigureAwait(false); break; } } indexDefinition.CloudTableEntities.Clear(); } }
private async Task WriteIndexDefinitionsToTableAsync(SaveType batchOperation) { for (var i = 0; i < IndexDefinitions.Count; i++) { var indexDefinition = IndexDefinitions[i]; if (indexDefinition.CloudTableEntities.Count > 0) { var entitiesArray = indexDefinition.CloudTableEntities.ToArray(); switch (batchOperation) { case SaveType.InsertOrReplace: await TableOperationsService.InsertOrReplaceAsync(entitiesArray).ConfigureAwait(false); break; case SaveType.InsertOrMerge: // Even if the client calls for a merge we need to replace since the whole object is being serialized anyways. await TableOperationsService.InsertOrReplaceAsync(entitiesArray).ConfigureAwait(false); break; case SaveType.Insert: await TableOperationsService.InsertAsync(entitiesArray).ConfigureAwait(false); break; case SaveType.Replace: await TableOperationsService.ReplaceAsync(entitiesArray).ConfigureAwait(false); break; case SaveType.Delete: await TableOperationsService.DeleteAsync(entitiesArray).ConfigureAwait(false); break; } } indexDefinition.CloudTableEntities.Clear(); } }
/// <summary> /// Deletes all instances from a particular index. Under the hood this is deleting everything inside /// a Table Partition. /// </summary> /// <param name="indexNameKey"></param> /// <returns></returns> public async Task DeleteAllItemsFromIndexAsync(string indexNameKey) { var entities = await TableOperationsService.GetByPartitionKeyAsync(indexNameKey).ConfigureAwait(false); await TableOperationsService.DeleteAsync(entities.ToArray()).ConfigureAwait(false); }