/// <summary>
        /// Deletes a single row
        /// <param name="storage">Table storage reference</param>
        /// <param name="tableName">Table name, required.</param>
        /// <param name="rowId">Row ID to delete, required.</param>
        /// </summary>
        public static async Task DeleteAsync(this ITableStorage storage, string tableName, TableRowId rowId)
        {
            if (rowId == null)
            {
                return;
            }

            await storage.DeleteAsync(tableName, new[] { rowId });
        }
        public void Write(string key, string value)
        {
            var rowId = new TableRowId(_partitionKey, key);

            if (value == null)
            {
                _tableStorage.DeleteAsync(_tableName, new[] { rowId }).Wait();
            }
            else
            {
                var row = new TableRow(rowId);
                row["value"] = value;
                _tableStorage.InsertOrReplaceAsync(_tableName, new[] { row }).Wait();
            }
        }
        public async Task Upload()
        {
            var existingSearchTerms = (await _tableStorage.GetAllAsync <GlobalSearchTerm>("searchTerms")).ToList();

            var i = 1;

            Parallel.ForEach(existingSearchTerms, new ParallelOptions {
                MaxDegreeOfParallelism = Environment.ProcessorCount
            }, async existingSearchTerm =>
            {
                await _tableStorage.DeleteAsync("searchTerms", existingSearchTerm);
                Console.WriteLine($"Deleted {i} of {existingSearchTerms.Count} existing search terms.");
                i++;
            });

            foreach (var globalSearchTerm in _globalSearchTermRepository.SearchTerms)
            {
                globalSearchTerm.LanguageEnum = _localization.Language;
            }

            await _tableStorage.AddBatchAsync <GlobalSearchTerm>("searchTerms",
                                                                 _globalSearchTermRepository.SearchTerms.Where(s =>
                                                                                                               s.PartitionKey == ContentType.ExpandedContent.ToString()),
                                                                 new BatchOperationOptions { BatchInsertMethod = BatchInsertMethod.Insert });

            await _tableStorage.AddBatchAsync <GlobalSearchTerm>("searchTerms",
                                                                 _globalSearchTermRepository.SearchTerms.Where(s =>
                                                                                                               s.PartitionKey == ContentType.Core.ToString()),
                                                                 new BatchOperationOptions { BatchInsertMethod = BatchInsertMethod.Insert });

            var index = await _searchServiceClient.Indexes.GetAsync("searchterms-index");

            await _searchServiceClient.Indexes.DeleteAsync("searchterms-index");

            await _searchServiceClient.Indexes.CreateAsync(index);

            await _searchServiceClient.Indexers.RunAsync("searchterms-indexer");
        }
        public override void Dispose()
        {
            _tables.DeleteAsync(_tableName).Wait();

            _tables.Dispose();

            Cleanup();

            base.Dispose();
        }
Exemple #5
0
 public void Delete(string rowKey, string partitionKey)
 {
     _azureProductRepository.DeleteAsync(partitionKey, rowKey);
 }