public async Task <List <T> > OutputData <T>(string accountName, string accountKey, string tableName) where T : TableEntity, new() { var DataList = new List <T>(); var tableService = new CloudTableService(); var table = tableService.GetAuthTable(accountName, accountKey, tableName); var condition = ""; if (tableName == "PreliminaryData") { condition = TableQuery.GenerateFilterConditionForBool("IsProcessed", QueryComparisons.Equal, false); } else { condition = TableQuery.GenerateFilterConditionForInt("ManuallyEvalutate", QueryComparisons.Equal, 0); } var query = new TableQuery <T>().Where(condition); TableContinuationToken token = null; do { var segment = await table.ExecuteQuerySegmentedAsync(query, token); foreach (T entity in segment) { DataList.Add(entity); } token = segment.ContinuationToken; }while (token != null); return(DataList); }
public async Task <bool> InsertData <T>(List <T> entities, string accountName, string accountKey, string tableName) where T : ITableEntity { var tablesBatch = new TableBatchOperation(); var tableService = new CloudTableService(); var table = tableService.GetAuthTable(accountName, accountKey, tableName); for (int i = 0; i < entities.Count; i++) { var insert = TableOperation.InsertOrReplace(entities[i]); tablesBatch.Add(insert); } await table.ExecuteBatchAsync(tablesBatch); return(true); }