Skip to content

Commit def8df1

Browse files
authored
Expose select query option on GetEntity (Azure#15161)
* Expose select query option on GetEntity
1 parent a827e82 commit def8df1

File tree

8 files changed

+723
-8
lines changed

8 files changed

+723
-8
lines changed

sdk/tables/Azure.Data.Tables/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
## 3.0.0-beta.2 (Unreleased)
44

5+
### Changed
6+
7+
- `TableClient`'s `GetEntity` method now exposes the `select` query option to allow for more efficient existence checks for a table entity
58

69
## 3.0.0-beta.1 (2020-09-08)
710

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
@@ -28,8 +28,8 @@ public TableClient(System.Uri endpoint, string tableName, Azure.Data.Tables.Tabl
2828
public virtual System.Threading.Tasks.Task<Azure.Response> DeleteEntityAsync(string partitionKey, string rowKey, Azure.ETag ifMatch = default(Azure.ETag), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
2929
public virtual Azure.Response<System.Collections.Generic.IReadOnlyList<Azure.Data.Tables.Models.SignedIdentifier>> GetAccessPolicy(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
3030
public virtual System.Threading.Tasks.Task<Azure.Response<System.Collections.Generic.IReadOnlyList<Azure.Data.Tables.Models.SignedIdentifier>>> GetAccessPolicyAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
31-
public virtual System.Threading.Tasks.Task<Azure.Response<T>> GetEntityAsync<T>(string partitionKey, string rowKey, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) where T : class, Azure.Data.Tables.ITableEntity, new() { throw null; }
32-
public virtual Azure.Response<T> GetEntity<T>(string partitionKey, string rowKey, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) where T : class, Azure.Data.Tables.ITableEntity, new() { throw null; }
31+
public virtual System.Threading.Tasks.Task<Azure.Response<T>> GetEntityAsync<T>(string partitionKey, string rowKey, System.Collections.Generic.IEnumerable<string> select = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) where T : class, Azure.Data.Tables.ITableEntity, new() { throw null; }
32+
public virtual Azure.Response<T> GetEntity<T>(string partitionKey, string rowKey, System.Collections.Generic.IEnumerable<string> select = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) where T : class, Azure.Data.Tables.ITableEntity, new() { throw null; }
3333
public virtual Azure.Data.Tables.Sas.TableSasBuilder GetSasBuilder(Azure.Data.Tables.Sas.TableSasPermissions permissions, System.DateTimeOffset expiresOn) { throw null; }
3434
public virtual Azure.Data.Tables.Sas.TableSasBuilder GetSasBuilder(string rawPermissions, System.DateTimeOffset expiresOn) { throw null; }
3535
public virtual Azure.AsyncPageable<T> QueryAsync<T>(System.Linq.Expressions.Expression<System.Func<T, bool>> filter, int? maxPerPage = default(int?), System.Collections.Generic.IEnumerable<string> select = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) where T : class, Azure.Data.Tables.ITableEntity, new() { throw null; }

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

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -408,15 +408,18 @@ public virtual async Task<Response> DeleteAsync(CancellationToken cancellationTo
408408
/// </summary>
409409
/// <param name="partitionKey">The partitionKey that identifies the table entity.</param>
410410
/// <param name="rowKey">The rowKey that identifies the table entity.</param>
411+
/// <param name="select">Selects which set of entity properties to return in the result set.</param>
411412
/// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param>
412413
/// <returns>The <see cref="Response"/> indicating the result of the operation.</returns>
413414
/// <exception cref="RequestFailedException">Exception thrown if the entity doesn't exist.</exception>
414415
/// <exception cref="ArgumentNullException"><paramref name="partitionKey"/> or <paramref name="rowKey"/> is null.</exception>
415-
public virtual Response<T> GetEntity<T>(string partitionKey, string rowKey, CancellationToken cancellationToken = default) where T : class, ITableEntity, new()
416+
public virtual Response<T> GetEntity<T>(string partitionKey, string rowKey, IEnumerable<string> select = null, CancellationToken cancellationToken = default) where T : class, ITableEntity, new()
416417
{
417418
Argument.AssertNotNull("message", nameof(partitionKey));
418419
Argument.AssertNotNull("message", nameof(rowKey));
419420

421+
string selectArg = select == null ? null : string.Join(",", select);
422+
420423
using DiagnosticScope scope = _diagnostics.CreateScope($"{nameof(TableClient)}.{nameof(GetEntity)}");
421424
scope.Start();
422425
try
@@ -425,7 +428,7 @@ public virtual async Task<Response> DeleteAsync(CancellationToken cancellationTo
425428
_table,
426429
partitionKey,
427430
rowKey,
428-
queryOptions: new QueryOptions() { Format = _format },
431+
queryOptions: new QueryOptions() { Format = _format, Select = selectArg },
429432
cancellationToken: cancellationToken);
430433

431434
var result = ((Dictionary<string, object>)response.Value).ToTableEntity<T>();
@@ -443,15 +446,18 @@ public virtual async Task<Response> DeleteAsync(CancellationToken cancellationTo
443446
/// </summary>
444447
/// <param name="partitionKey">The partitionKey that identifies the table entity.</param>
445448
/// <param name="rowKey">The rowKey that identifies the table entity.</param>
449+
/// <param name="select">Selects which set of entity properties to return in the result set.</param>
446450
/// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param>
447451
/// <returns>The <see cref="Response"/> indicating the result of the operation.</returns>
448452
/// <exception cref="RequestFailedException">Exception thrown if the entity doesn't exist.</exception>
449453
/// <exception cref="ArgumentNullException"><paramref name="partitionKey"/> or <paramref name="rowKey"/> is null.</exception>
450-
public virtual async Task<Response<T>> GetEntityAsync<T>(string partitionKey, string rowKey, CancellationToken cancellationToken = default) where T : class, ITableEntity, new()
454+
public virtual async Task<Response<T>> GetEntityAsync<T>(string partitionKey, string rowKey, IEnumerable<string> select = null, CancellationToken cancellationToken = default) where T : class, ITableEntity, new()
451455
{
452456
Argument.AssertNotNull("message", nameof(partitionKey));
453457
Argument.AssertNotNull("message", nameof(rowKey));
454458

459+
string selectArg = select == null ? null : string.Join(",", select);
460+
455461
using DiagnosticScope scope = _diagnostics.CreateScope($"{nameof(TableClient)}.{nameof(GetEntity)}");
456462
scope.Start();
457463
try
@@ -460,7 +466,7 @@ public virtual async Task<Response> DeleteAsync(CancellationToken cancellationTo
460466
_table,
461467
partitionKey,
462468
rowKey,
463-
queryOptions: new QueryOptions() { Format = _format },
469+
queryOptions: new QueryOptions() { Format = _format, Select = selectArg },
464470
cancellationToken: cancellationToken).ConfigureAwait(false);
465471

466472
var result = ((Dictionary<string, object>)response.Value).ToTableEntity<T>();

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

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

0 commit comments

Comments
 (0)