コード例 #1
0
 private static async Task DeleteByPartitionsAsync(string[] partitions, string[] entries, IActivityTracker <DynamicTableEntity> journal)
 {
     foreach (var partition in partitions)
     {
         foreach (var entry in entries)
         {
             await journal.DeleteAsync(new Identifier(entry, partition));
         }
     }
 }
コード例 #2
0
        public async Task CRUDGlobalAsync()
        {
            var query   = new MetricQueryableFactory <DynamicTableEntity>().Create((string)null);
            var hasRows = (await query.GetAsync(_JournalTableName, 1)).Results.Count > 0;

            if (hasRows)
            {
                var allRows = await query.GetAsync(_JournalTableName);

                foreach (var row in allRows.Results)
                {
                    await _Journal.DeleteAsync(new Identifier( row.RowKey, row.PartitionKey));
                }
            }

            //Create
            await InsertByPartitionsAsync(_PartitionKeys, _RowKeys, _Journal);

            //Read 1
            var rows = await query.GetAsync(_JournalTableName, null, new QueryFilter("PartitionKey", "A"), new QueryFilter("RowKey", "01"));

            Assert.IsTrue(rows.Results.Count == 1, "Wrong number of rows returned - 1");

            //Read 2
            var rows2 = await query.GetAsync(_JournalTableName, null, new QueryFilter("RowKey", "01"));

            Assert.IsTrue(rows2.Results.Count == _PartitionKeys.Length, "Wrong number of rows returned - 2");

            //Read 2.5
            var rows25 = await query.GetAsync(_JournalTableName, 1, new QueryFilter("RowKey", "01"));

            Assert.IsTrue(rows25.Results.Count == 1, "Wrong number of rows returned - 2.5");

            //Read 3
            var rows3 = await query.GetAsync(_JournalTableName, null, new QueryFilter("PartitionKey", "A"));

            Assert.IsTrue(rows3.Results.Count == _RowKeys.Length, "Wrong number of rows returned - 3");

            //Delete
            await DeleteByPartitionsAsync(_PartitionKeys, _RowKeys, _Journal);
        }