Beispiel #1
0
 public Task InsertAsync(IEnumerable <T> items)
 {
     items = items.ToArray();
     try
     {
         if (items.Any())
         {
             var insertBatchOperation = new TableBatchOperation();
             foreach (var item in items)
             {
                 insertBatchOperation.Insert(item);
             }
             return(GetTable().ExecuteBatchAsync(insertBatchOperation));
         }
     }
     catch (Exception ex)
     {
         _log?.WriteFatalError("Table storage: " + _tableName, "InsertAsync batch",
                               AzureStorageUtils.PrintItems(items), ex);
     }
     return(Task.CompletedTask);
 }
        public async Task DeleteAsync(IEnumerable <T> items)
        {
            items = items.ToArray();
            try
            {
                if (items.Any())
                {
                    var deleteBatchOperation = new TableBatchOperation();
                    foreach (var item in items)
                    {
                        deleteBatchOperation.Delete(item);
                    }
                    var table = await GetTable();

                    await table.ExecuteBatchAsync(deleteBatchOperation);
                }
            }
            catch (Exception ex)
            {
                _log?.WriteFatalErrorAsync("Table storage: " + _tableName, "DeleteAsync batch",
                                           AzureStorageUtils.PrintItems(items), ex);
            }
        }
        public async Task InsertAsync(IEnumerable <T> items)
        {
            items = items.ToArray();
            try
            {
                if (items.Any())
                {
                    var insertBatchOperation = new TableBatchOperation();
                    foreach (var item in items)
                    {
                        insertBatchOperation.Insert(item);
                    }
                    var table = await GetTable();

                    await table.ExecuteBatchAsync(insertBatchOperation, GetRequestOptions(), null);
                }
            }
            catch (Exception ex)
            {
                await _log.WriteFatalErrorAsync("Table storage: " + _tableName, "InsertAsync batch", AzureStorageUtils.PrintItems(items), ex);

                throw;
            }
        }