Skip to content

Commit d89dbc0

Browse files
authored
Default to ResponseFormat.ReturnNoContent on AddEntity (Azure#14462)
* Default to ResponseFormat.ReturnNoContent on AddEntity * export * update xml docs
1 parent d14fe9a commit d89dbc0

File tree

168 files changed

+15843
-34381
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

168 files changed

+15843
-34381
lines changed

sdk/tables/Azure.Data.Tables/api/Azure.Data.Tables.netstandard2.0.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ protected TableClient() { }
1313
public TableClient(string tableName, System.Uri endpoint, Azure.Data.Tables.TableClientOptions options = null) { }
1414
public TableClient(string tableName, System.Uri endpoint, Azure.Data.Tables.TableSharedKeyCredential credential) { }
1515
public TableClient(string tableName, System.Uri endpoint, Azure.Data.Tables.TableSharedKeyCredential credential, Azure.Data.Tables.TableClientOptions options = null) { }
16-
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; }
17-
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; }
16+
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; }
17+
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; }
1818
public virtual Azure.Response<Azure.Data.Tables.Models.TableItem> Create(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
1919
public virtual System.Threading.Tasks.Task<Azure.Response<Azure.Data.Tables.Models.TableItem>> CreateAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
2020
public virtual Azure.Response<Azure.Data.Tables.Models.TableItem> CreateIfNotExists(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }

sdk/tables/Azure.Data.Tables/src/TableClient.cs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ public class TableClient
2727
private readonly TableRestClient _tableOperations;
2828
private readonly string _version;
2929
private readonly bool _isPremiumEndpoint;
30+
private ResponseFormat _returnNoContent = ResponseFormat.ReturnNoContent;
3031

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

306-
var result = ((Dictionary<string, object>)response.Value).ToTableEntity<T>();
307-
return Response.FromValue(result, response.GetRawResponse());
308+
return response.GetRawResponse();
308309
}
309310
catch (Exception ex)
310311
{
@@ -318,9 +319,9 @@ public virtual async Task<Response> DeleteAsync(CancellationToken cancellationTo
318319
/// </summary>
319320
/// <param name="entity">The entity to add.</param>
320321
/// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param>
321-
/// <returns>The added Table entity.</returns>
322+
/// <returns>A <see cref="Response"/> containing headers such as ETag</returns>
322323
/// <exception cref="RequestFailedException">Exception thrown if entity already exists.</exception>
323-
public virtual Response<T> AddEntity<T>(T entity, CancellationToken cancellationToken = default) where T : class, ITableEntity, new()
324+
public virtual Response AddEntity<T>(T entity, CancellationToken cancellationToken = default) where T : class, ITableEntity, new()
324325
{
325326
Argument.AssertNotNull(entity, nameof(entity));
326327
Argument.AssertNotNull(entity?.PartitionKey, nameof(entity.PartitionKey));
@@ -331,11 +332,11 @@ public virtual async Task<Response> DeleteAsync(CancellationToken cancellationTo
331332
{
332333
var response = _tableOperations.InsertEntity(_table,
333334
tableEntityProperties: entity.ToOdataAnnotatedDictionary(),
335+
responsePreference: _returnNoContent,
334336
queryOptions: new QueryOptions() { Format = _format },
335337
cancellationToken: cancellationToken);
336338

337-
var result = ((Dictionary<string, object>)response.Value).ToTableEntity<T>();
338-
return Response.FromValue(result, response.GetRawResponse());
339+
return response.GetRawResponse();
339340
}
340341
catch (Exception ex)
341342
{

sdk/tables/Azure.Data.Tables/tests/SessionRecords/TableClientLiveTests(CosmosTable)/CreateEntityReturnsEntitiesWithoutOdataAnnoations.json

Lines changed: 50 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sdk/tables/Azure.Data.Tables/tests/SessionRecords/TableClientLiveTests(CosmosTable)/CreateEntityReturnsEntitiesWithoutOdataAnnoationsAsync.json

Lines changed: 54 additions & 24 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)