예제 #1
0
        public virtual async Task <TEntity?> Retrieve <TEntity>(string partitionKey, string rowKey)
            where TEntity : class, ITableEntity, new()
        {
            Guard.NullOrWhiteSpace(nameof(partitionKey), partitionKey);
            Guard.NullOrWhiteSpace(nameof(rowKey), rowKey);

            await this.ExistenceTester.EnsureExists(this.Table).ConfigureAwait(false);

            TableOperation retrieve = TableOperation.Retrieve <TEntity>(partitionKey, rowKey);

            TableResult result = await this.Table.ExecuteAsync(retrieve, this.Options,
                                                               operationContext : null).ConfigureAwait(false);

            if (result.HttpStatusCode == 404)
            {
                return(null);
            }

            result.EnsureSuccessStatusCode();

            return((TEntity)result.Result);
        }