示例#1
0
        public async Task DeleteByPartition()
        {
            var random    = new Random();
            var count     = random.Next(1, 25);
            var entities  = new List <Helper>();
            var partition = Guid.NewGuid().ToString();

            for (var i = 0; i < count; i++)
            {
                var h = new Helper()
                {
                    PartitionKey = partition,
                    RowKey       = Guid.NewGuid().ToString(),
                    Id           = Guid.NewGuid(),
                };
                entities.Add(h);
            }

            await storage.Insert(entities);

            await storage.DeleteByPartition(partition);

            var returned = await storage.QueryByPartition <Helper>(partition);

            Assert.IsNotNull(returned);
            Assert.IsFalse(returned.Any());
        }
示例#2
0
        public async Task InsertDictionaryBatch()
        {
            var random    = new Random();
            var count     = random.Next(1, 25);
            var partition = Guid.NewGuid().ToString();
            var entities  = new List <IDictionary <string, object> >(count);

            for (var i = 0; i < count; i++)
            {
                var dic = new Dictionary <string, object>();
                dic.Add(TableStorage.PartitionKey, partition);
                dic.Add(TableStorage.RowKey, Guid.NewGuid());
                dic.Add("Extraa", DateTime.UtcNow);
                entities.Add(dic);
            }
            var result = await storage.Insert(entities);

            var query = new TableQuery();

            query.Where(TableQuery.GenerateFilterCondition(TableStorage.PartitionKey, QueryComparisons.Equal, partition));
            var returned = await storage.Query(query);

            Assert.IsNotNull(returned);
            Assert.AreEqual(count, returned.Count());
            await storage.DeleteByPartition(partition);
        }