Ejemplo n.º 1
0
        public static async Task RemoveAsync(
            this CloudTable table,
            KeysPair keys)
        {
            try
            {
                var entity = new DynamicTableEntity(keys.PartitionKey, keys.RowKey)
                {
                    ETag = "*"
                };
                await table.ExecuteAsync(TableOperation.Delete(entity))
                .ConfigureAwait(false);
            }
            catch (StorageException ex)
            {
                var requestInformation = ex.RequestInformation;
                if (requestInformation != null && requestInformation.HttpStatusCode == 404)
                {
                    // Do nothing
                    return;
                }

                throw ex;
            }
        }
Ejemplo n.º 2
0
 public static async Task <DynamicTableEntity> Wrap <TPayload>(this KeysPair keyPair, TPayload payload)
 {
     return(await Task.Factory.StartNew(() =>
     {
         return new DynamicTableEntity(keyPair.PartitionKey, keyPair.RowKey)
         {
             Timestamp = DateTime.UtcNow,
             Properties = EntityPropertyConverter.Flatten(payload, new OperationContext()),
             ETag = "*"
         };
     }).ConfigureAwait(false));
 }
Ejemplo n.º 3
0
        public static async Task AddAsync <TPayload>(
            this CloudTable table, TPayload payload,
            KeysPair keys)
        {
            Ensure.ArgumentNotNull(keys, nameof(keys));
            Ensure.ArgumentNotNull(payload, nameof(payload));
            Ensure.ArgumentNotNull(table, nameof(table));

            await table.ExecuteAsync(
                TableOperation.Insert(
                    new DynamicTableEntity(keys.PartitionKey, keys.RowKey)
            {
                Timestamp  = DateTime.UtcNow,
                Properties = EntityPropertyConverter.Flatten(payload, new OperationContext())
            }))
            .ConfigureAwait(false);
        }