Skip to content

Commit

Permalink
Default to ResponseFormat.ReturnNoContent on AddEntity (Azure#14462)
Browse files Browse the repository at this point in the history
* Default to ResponseFormat.ReturnNoContent on AddEntity

* export

* update xml docs
  • Loading branch information
christothes authored Aug 21, 2020
1 parent d14fe9a commit d89dbc0
Show file tree
Hide file tree
Showing 168 changed files with 15,843 additions and 34,381 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ protected TableClient() { }
public TableClient(string tableName, System.Uri endpoint, Azure.Data.Tables.TableClientOptions options = null) { }
public TableClient(string tableName, System.Uri endpoint, Azure.Data.Tables.TableSharedKeyCredential credential) { }
public TableClient(string tableName, System.Uri endpoint, Azure.Data.Tables.TableSharedKeyCredential credential, Azure.Data.Tables.TableClientOptions options = null) { }
public virtual System.Threading.Tasks.Task<Azure.Response<T>> AddEntityAsync<T>(T entity, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) where T : class, Azure.Data.Tables.ITableEntity, new() { throw null; }
public virtual Azure.Response<T> AddEntity<T>(T entity, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) where T : class, Azure.Data.Tables.ITableEntity, new() { throw null; }
public virtual System.Threading.Tasks.Task<Azure.Response> AddEntityAsync<T>(T entity, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) where T : class, Azure.Data.Tables.ITableEntity, new() { throw null; }
public virtual Azure.Response AddEntity<T>(T entity, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) where T : class, Azure.Data.Tables.ITableEntity, new() { throw null; }
public virtual Azure.Response<Azure.Data.Tables.Models.TableItem> Create(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual System.Threading.Tasks.Task<Azure.Response<Azure.Data.Tables.Models.TableItem>> CreateAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual Azure.Response<Azure.Data.Tables.Models.TableItem> CreateIfNotExists(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
Expand Down
17 changes: 9 additions & 8 deletions sdk/tables/Azure.Data.Tables/src/TableClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public class TableClient
private readonly TableRestClient _tableOperations;
private readonly string _version;
private readonly bool _isPremiumEndpoint;
private ResponseFormat _returnNoContent = ResponseFormat.ReturnNoContent;

/// <summary>
/// Initializes a new instance of the <see cref="TableClient"/>.
Expand Down Expand Up @@ -287,9 +288,9 @@ public virtual async Task<Response> DeleteAsync(CancellationToken cancellationTo
/// <param name="entity">The entity to add.</param>
/// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param>
/// <exception cref="RequestFailedException">The server returned an error. See <see cref="Exception.Message"/> for details returned from the server.</exception>
/// <returns>The added Table entity.</returns>
/// <returns>A <see cref="Response"/> containing headers such as ETag.</returns>
/// <exception cref="RequestFailedException">Exception thrown if entity already exists.</exception>
public virtual async Task<Response<T>> AddEntityAsync<T>(T entity, CancellationToken cancellationToken = default) where T : class, ITableEntity, new()
public virtual async Task<Response> AddEntityAsync<T>(T entity, CancellationToken cancellationToken = default) where T : class, ITableEntity, new()
{
Argument.AssertNotNull(entity, nameof(entity));
Argument.AssertNotNull(entity?.PartitionKey, nameof(entity.PartitionKey));
Expand All @@ -300,11 +301,11 @@ public virtual async Task<Response> DeleteAsync(CancellationToken cancellationTo
{
var response = await _tableOperations.InsertEntityAsync(_table,
tableEntityProperties: entity.ToOdataAnnotatedDictionary(),
responsePreference: _returnNoContent,
queryOptions: new QueryOptions() { Format = _format },
cancellationToken: cancellationToken).ConfigureAwait(false);

var result = ((Dictionary<string, object>)response.Value).ToTableEntity<T>();
return Response.FromValue(result, response.GetRawResponse());
return response.GetRawResponse();
}
catch (Exception ex)
{
Expand All @@ -318,9 +319,9 @@ public virtual async Task<Response> DeleteAsync(CancellationToken cancellationTo
/// </summary>
/// <param name="entity">The entity to add.</param>
/// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param>
/// <returns>The added Table entity.</returns>
/// <returns>A <see cref="Response"/> containing headers such as ETag</returns>
/// <exception cref="RequestFailedException">Exception thrown if entity already exists.</exception>
public virtual Response<T> AddEntity<T>(T entity, CancellationToken cancellationToken = default) where T : class, ITableEntity, new()
public virtual Response AddEntity<T>(T entity, CancellationToken cancellationToken = default) where T : class, ITableEntity, new()
{
Argument.AssertNotNull(entity, nameof(entity));
Argument.AssertNotNull(entity?.PartitionKey, nameof(entity.PartitionKey));
Expand All @@ -331,11 +332,11 @@ public virtual async Task<Response> DeleteAsync(CancellationToken cancellationTo
{
var response = _tableOperations.InsertEntity(_table,
tableEntityProperties: entity.ToOdataAnnotatedDictionary(),
responsePreference: _returnNoContent,
queryOptions: new QueryOptions() { Format = _format },
cancellationToken: cancellationToken);

var result = ((Dictionary<string, object>)response.Value).ToTableEntity<T>();
return Response.FromValue(result, response.GetRawResponse());
return response.GetRawResponse();
}
catch (Exception ex)
{
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit d89dbc0

Please sign in to comment.