public async Task <T> Get <T>(string partitionKey, string rowKey) where T : class, ITableEntity, new()
        {
            partitionKey.CheckNotNull(nameof(partitionKey));
            rowKey.CheckNotNull(nameof(rowKey));

            /* This will throw a storage exception if it fails to acquire the lock */

            var response = await tableStorageProvider.Get <T>(partitionKey, rowKey);

            return(response?.Result);
        }
Esempio n. 2
0
        public async Task Hold(string partitionKey, string rowKey)
        {
            await this.mutex.AcquireAsync();

            var entity = await tableStorageProvider.Get <T>(partitionKey, rowKey);

            this.Entity = entity.Result;

            if (this.Entity == null)
            {
                IsNew = true;

                this.Entity = Activator.CreateInstance <T>();
                this.Entity.PartitionKey = tableStorageProvider.ToKey(partitionKey);
                this.Entity.RowKey       = tableStorageProvider.ToKey(rowKey);
            }

            this.Entity.ETag = "*"; // ML - Ensure clobbering happens as we have a lock
        }