diff --git a/sdk/tables/Azure.Data.Tables/CHANGELOG.md b/sdk/tables/Azure.Data.Tables/CHANGELOG.md index 1420b7c323365..a02807efb3d09 100644 --- a/sdk/tables/Azure.Data.Tables/CHANGELOG.md +++ b/sdk/tables/Azure.Data.Tables/CHANGELOG.md @@ -2,6 +2,9 @@ ## 3.0.0-beta.2 (Unreleased) +### Changed + +- `TableClient`'s `GetEntity` method now exposes the `select` query option to allow for more efficient existence checks for a table entity ## 3.0.0-beta.1 (2020-09-08) diff --git a/sdk/tables/Azure.Data.Tables/api/Azure.Data.Tables.netstandard2.0.cs b/sdk/tables/Azure.Data.Tables/api/Azure.Data.Tables.netstandard2.0.cs index 67d31bb44c453..bac2860ff6724 100644 --- a/sdk/tables/Azure.Data.Tables/api/Azure.Data.Tables.netstandard2.0.cs +++ b/sdk/tables/Azure.Data.Tables/api/Azure.Data.Tables.netstandard2.0.cs @@ -28,8 +28,8 @@ public TableClient(System.Uri endpoint, string tableName, Azure.Data.Tables.Tabl public virtual System.Threading.Tasks.Task DeleteEntityAsync(string partitionKey, string rowKey, Azure.ETag ifMatch = default(Azure.ETag), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual Azure.Response> GetAccessPolicy(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } public virtual System.Threading.Tasks.Task>> GetAccessPolicyAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual System.Threading.Tasks.Task> GetEntityAsync(string partitionKey, string rowKey, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) where T : class, Azure.Data.Tables.ITableEntity, new() { throw null; } - public virtual Azure.Response GetEntity(string partitionKey, string rowKey, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) where T : class, Azure.Data.Tables.ITableEntity, new() { throw null; } + public virtual System.Threading.Tasks.Task> GetEntityAsync(string partitionKey, string rowKey, System.Collections.Generic.IEnumerable select = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) where T : class, Azure.Data.Tables.ITableEntity, new() { throw null; } + public virtual Azure.Response GetEntity(string partitionKey, string rowKey, System.Collections.Generic.IEnumerable select = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) where T : class, Azure.Data.Tables.ITableEntity, new() { throw null; } public virtual Azure.Data.Tables.Sas.TableSasBuilder GetSasBuilder(Azure.Data.Tables.Sas.TableSasPermissions permissions, System.DateTimeOffset expiresOn) { throw null; } public virtual Azure.Data.Tables.Sas.TableSasBuilder GetSasBuilder(string rawPermissions, System.DateTimeOffset expiresOn) { throw null; } public virtual Azure.AsyncPageable QueryAsync(System.Linq.Expressions.Expression> filter, int? maxPerPage = default(int?), System.Collections.Generic.IEnumerable select = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) where T : class, Azure.Data.Tables.ITableEntity, new() { throw null; } diff --git a/sdk/tables/Azure.Data.Tables/src/TableClient.cs b/sdk/tables/Azure.Data.Tables/src/TableClient.cs index 5f7ddf3993121..20424336639bb 100644 --- a/sdk/tables/Azure.Data.Tables/src/TableClient.cs +++ b/sdk/tables/Azure.Data.Tables/src/TableClient.cs @@ -408,15 +408,18 @@ public virtual async Task DeleteAsync(CancellationToken cancellationTo /// /// The partitionKey that identifies the table entity. /// The rowKey that identifies the table entity. + /// Selects which set of entity properties to return in the result set. /// A controlling the request lifetime. /// The indicating the result of the operation. /// Exception thrown if the entity doesn't exist. /// or is null. - public virtual Response GetEntity(string partitionKey, string rowKey, CancellationToken cancellationToken = default) where T : class, ITableEntity, new() + public virtual Response GetEntity(string partitionKey, string rowKey, IEnumerable select = null, CancellationToken cancellationToken = default) where T : class, ITableEntity, new() { Argument.AssertNotNull("message", nameof(partitionKey)); Argument.AssertNotNull("message", nameof(rowKey)); + string selectArg = select == null ? null : string.Join(",", select); + using DiagnosticScope scope = _diagnostics.CreateScope($"{nameof(TableClient)}.{nameof(GetEntity)}"); scope.Start(); try @@ -425,7 +428,7 @@ public virtual async Task DeleteAsync(CancellationToken cancellationTo _table, partitionKey, rowKey, - queryOptions: new QueryOptions() { Format = _format }, + queryOptions: new QueryOptions() { Format = _format, Select = selectArg }, cancellationToken: cancellationToken); var result = ((Dictionary)response.Value).ToTableEntity(); @@ -443,15 +446,18 @@ public virtual async Task DeleteAsync(CancellationToken cancellationTo /// /// The partitionKey that identifies the table entity. /// The rowKey that identifies the table entity. + /// Selects which set of entity properties to return in the result set. /// A controlling the request lifetime. /// The indicating the result of the operation. /// Exception thrown if the entity doesn't exist. /// or is null. - public virtual async Task> GetEntityAsync(string partitionKey, string rowKey, CancellationToken cancellationToken = default) where T : class, ITableEntity, new() + public virtual async Task> GetEntityAsync(string partitionKey, string rowKey, IEnumerable select = null, CancellationToken cancellationToken = default) where T : class, ITableEntity, new() { Argument.AssertNotNull("message", nameof(partitionKey)); Argument.AssertNotNull("message", nameof(rowKey)); + string selectArg = select == null ? null : string.Join(",", select); + using DiagnosticScope scope = _diagnostics.CreateScope($"{nameof(TableClient)}.{nameof(GetEntity)}"); scope.Start(); try @@ -460,7 +466,7 @@ public virtual async Task DeleteAsync(CancellationToken cancellationTo _table, partitionKey, rowKey, - queryOptions: new QueryOptions() { Format = _format }, + queryOptions: new QueryOptions() { Format = _format, Select = selectArg }, cancellationToken: cancellationToken).ConfigureAwait(false); var result = ((Dictionary)response.Value).ToTableEntity(); diff --git a/sdk/tables/Azure.Data.Tables/tests/SessionRecords/TableClientLiveTests(CosmosTable)/CreateEntityAllowsSelect.json b/sdk/tables/Azure.Data.Tables/tests/SessionRecords/TableClientLiveTests(CosmosTable)/CreateEntityAllowsSelect.json new file mode 100644 index 0000000000000..1352b7ae59608 --- /dev/null +++ b/sdk/tables/Azure.Data.Tables/tests/SessionRecords/TableClientLiveTests(CosmosTable)/CreateEntityAllowsSelect.json @@ -0,0 +1,156 @@ +{ + "Entries": [ + { + "RequestUri": "https://chrissprim.table.cosmos.azure.com/Tables?$format=application%2Fjson%3Bodata%3Dminimalmetadata", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "application/json", + "Authorization": "Sanitized", + "Content-Length": "33", + "Content-Type": "application/json; odata=nometadata", + "DataServiceVersion": "3.0", + "traceparent": "00-727637ac6ced3143a3edee628e9504f7-1cfbbb633b43674d-00", + "User-Agent": [ + "azsdk-net-Data.Tables/3.0.0-alpha.20200915.1", + "(.NET Core 4.6.29220.03; Microsoft Windows 10.0.18363 )" + ], + "x-ms-client-request-id": "ed401525fc3b5ef4dc3ee5737419cf24", + "x-ms-date": "Tue, 15 Sep 2020 16:44:22 GMT", + "x-ms-return-client-request-id": "true", + "x-ms-version": "2019-02-02" + }, + "RequestBody": { + "TableName": "testtable7k63e8da" + }, + "StatusCode": 201, + "ResponseHeaders": { + "Content-Type": "application/json", + "Date": "Tue, 15 Sep 2020 16:44:23 GMT", + "ETag": "W/\u0022datetime\u00272020-09-15T16%3A44%3A23.6059656Z\u0027\u0022", + "Location": "https://chrissprim.table.cosmos.azure.com/Tables(\u0027testtable7k63e8da\u0027)", + "Server": "Microsoft-HTTPAPI/2.0", + "Transfer-Encoding": "chunked", + "x-ms-request-id": "ed401525-fc3b-5ef4-dc3e-e5737419cf24" + }, + "ResponseBody": { + "TableName": "testtable7k63e8da", + "odata.metadata": "https://chrissprim.table.cosmos.azure.com/$metadata#Tables/@Element" + } + }, + { + "RequestUri": "https://chrissprim.table.cosmos.azure.com/testtable7k63e8da?$format=application%2Fjson%3Bodata%3Dminimalmetadata", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "application/json", + "Authorization": "Sanitized", + "Content-Length": "614", + "Content-Type": "application/json; odata=nometadata", + "DataServiceVersion": "3.0", + "Prefer": "return-no-content", + "traceparent": "00-0b73a3834350044091978495b9759c46-a2870cfd3a565945-00", + "User-Agent": [ + "azsdk-net-Data.Tables/3.0.0-alpha.20200915.1", + "(.NET Core 4.6.29220.03; Microsoft Windows 10.0.18363 )" + ], + "x-ms-client-request-id": "fd7813088e496ca90993e743787814e3", + "x-ms-date": "Tue, 15 Sep 2020 16:44:24 GMT", + "x-ms-return-client-request-id": "true", + "x-ms-version": "2019-02-02" + }, + "RequestBody": { + "PartitionKey": "somPartition", + "RowKey": "01", + "SomeStringProperty": "This is table entity number 01", + "SomeDateProperty": "2020-01-01T01:02:00.0000000Z", + "SomeDateProperty@odata.type": "Edm.DateTime", + "SomeGuidProperty": "0d391d16-97f1-4b9a-be68-4cc871f90001", + "SomeGuidProperty@odata.type": "Edm.Guid", + "SomeBinaryProperty": "AQIDBAU=", + "SomeBinaryProperty@odata.type": "Edm.Binary", + "SomeInt64Property": "1", + "SomeInt64Property@odata.type": "Edm.Int64", + "SomeDoubleProperty0": 1, + "SomeDoubleProperty0@odata.type": "Edm.Double", + "SomeDoubleProperty1": 1.1000000000000001, + "SomeDoubleProperty1@odata.type": "Edm.Double", + "SomeIntProperty": 1 + }, + "StatusCode": 204, + "ResponseHeaders": { + "Content-Length": "0", + "Date": "Tue, 15 Sep 2020 16:44:23 GMT", + "ETag": "W/\u0022datetime\u00272020-09-15T16%3A44%3A24.1640456Z\u0027\u0022", + "Location": "https://chrissprim.table.cosmos.azure.com/testtable7k63e8da(PartitionKey=\u0027somPartition\u0027,RowKey=\u002701\u0027)", + "Preference-Applied": "return-no-content", + "Server": "Microsoft-HTTPAPI/2.0", + "x-ms-request-id": "fd781308-8e49-6ca9-0993-e743787814e3" + }, + "ResponseBody": [] + }, + { + "RequestUri": "https://chrissprim.table.cosmos.azure.com/testtable7k63e8da(PartitionKey=\u0027somPartition\u0027,RowKey=\u002701\u0027)?$format=application%2Fjson%3Bodata%3Dminimalmetadata\u0026$select=PartitionKey", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": "application/json", + "Authorization": "Sanitized", + "DataServiceVersion": "3.0", + "traceparent": "00-028bce91ff85754e91dfd67d61df0278-dd3199cfbd790e43-00", + "User-Agent": [ + "azsdk-net-Data.Tables/3.0.0-alpha.20200915.1", + "(.NET Core 4.6.29220.03; Microsoft Windows 10.0.18363 )" + ], + "x-ms-client-request-id": "e5b87355ac2d70ea566479233dc540f3", + "x-ms-date": "Tue, 15 Sep 2020 16:44:24 GMT", + "x-ms-return-client-request-id": "true", + "x-ms-version": "2019-02-02" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Content-Type": "application/json", + "Date": "Tue, 15 Sep 2020 16:44:24 GMT", + "ETag": "W/\u0022datetime\u00272020-09-15T16%3A44%3A24.1640456Z\u0027\u0022", + "Server": "Microsoft-HTTPAPI/2.0", + "Transfer-Encoding": "chunked", + "x-ms-request-id": "e5b87355-ac2d-70ea-5664-79233dc540f3" + }, + "ResponseBody": { + "odata.metadata": "https://chrissprim.table.cosmos.azure.com/testtable7k63e8da/$metadata#testtable7k63e8da/@Element", + "odata.etag": "W/\u0022datetime\u00272020-09-15T16%3A44%3A24.1640456Z\u0027\u0022", + "PartitionKey": "somPartition" + } + }, + { + "RequestUri": "https://chrissprim.table.cosmos.azure.com/Tables(\u0027testtable7k63e8da\u0027)", + "RequestMethod": "DELETE", + "RequestHeaders": { + "Accept": "application/json", + "Authorization": "Sanitized", + "traceparent": "00-9477c24f75f0d74ba297a4f06997ddd7-9ff99a3204be784a-00", + "User-Agent": [ + "azsdk-net-Data.Tables/3.0.0-alpha.20200915.1", + "(.NET Core 4.6.29220.03; Microsoft Windows 10.0.18363 )" + ], + "x-ms-client-request-id": "ca543afcf89196726cd4e3a815b0e663", + "x-ms-date": "Tue, 15 Sep 2020 16:44:24 GMT", + "x-ms-return-client-request-id": "true", + "x-ms-version": "2019-02-02" + }, + "RequestBody": null, + "StatusCode": 204, + "ResponseHeaders": { + "Content-Length": "0", + "Date": "Tue, 15 Sep 2020 16:44:24 GMT", + "Server": "Microsoft-HTTPAPI/2.0", + "x-ms-request-id": "ca543afc-f891-9672-6cd4-e3a815b0e663" + }, + "ResponseBody": [] + } + ], + "Variables": { + "COSMOS_TABLES_ENDPOINT_SUFFIX": null, + "RandomSeed": "2078415884", + "TABLES_COSMOS_ACCOUNT_NAME": "chrissprim", + "TABLES_PRIMARY_COSMOS_ACCOUNT_KEY": "Kg==" + } +} \ No newline at end of file diff --git a/sdk/tables/Azure.Data.Tables/tests/SessionRecords/TableClientLiveTests(CosmosTable)/CreateEntityAllowsSelectAsync.json b/sdk/tables/Azure.Data.Tables/tests/SessionRecords/TableClientLiveTests(CosmosTable)/CreateEntityAllowsSelectAsync.json new file mode 100644 index 0000000000000..3fec059f282b0 --- /dev/null +++ b/sdk/tables/Azure.Data.Tables/tests/SessionRecords/TableClientLiveTests(CosmosTable)/CreateEntityAllowsSelectAsync.json @@ -0,0 +1,156 @@ +{ + "Entries": [ + { + "RequestUri": "https://chrissprim.table.cosmos.azure.com/Tables?$format=application%2Fjson%3Bodata%3Dminimalmetadata", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "application/json", + "Authorization": "Sanitized", + "Content-Length": "33", + "Content-Type": "application/json; odata=nometadata", + "DataServiceVersion": "3.0", + "traceparent": "00-69d6056dfc798f4fb2d9eeb88c9a1541-c1e5dfda77ea4a42-00", + "User-Agent": [ + "azsdk-net-Data.Tables/3.0.0-alpha.20200915.1", + "(.NET Core 4.6.29220.03; Microsoft Windows 10.0.18363 )" + ], + "x-ms-client-request-id": "65f71025823568f020c3321a0a5dd44d", + "x-ms-date": "Tue, 15 Sep 2020 16:44:25 GMT", + "x-ms-return-client-request-id": "true", + "x-ms-version": "2019-02-02" + }, + "RequestBody": { + "TableName": "testtabletat5i3e2" + }, + "StatusCode": 201, + "ResponseHeaders": { + "Content-Type": "application/json", + "Date": "Tue, 15 Sep 2020 16:44:25 GMT", + "ETag": "W/\u0022datetime\u00272020-09-15T16%3A44%3A25.2762120Z\u0027\u0022", + "Location": "https://chrissprim.table.cosmos.azure.com/Tables(\u0027testtabletat5i3e2\u0027)", + "Server": "Microsoft-HTTPAPI/2.0", + "Transfer-Encoding": "chunked", + "x-ms-request-id": "65f71025-8235-68f0-20c3-321a0a5dd44d" + }, + "ResponseBody": { + "TableName": "testtabletat5i3e2", + "odata.metadata": "https://chrissprim.table.cosmos.azure.com/$metadata#Tables/@Element" + } + }, + { + "RequestUri": "https://chrissprim.table.cosmos.azure.com/testtabletat5i3e2?$format=application%2Fjson%3Bodata%3Dminimalmetadata", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "application/json", + "Authorization": "Sanitized", + "Content-Length": "614", + "Content-Type": "application/json; odata=nometadata", + "DataServiceVersion": "3.0", + "Prefer": "return-no-content", + "traceparent": "00-057b4384a2aa3c43af5986366b48a84f-cb3e9884e1eb5647-00", + "User-Agent": [ + "azsdk-net-Data.Tables/3.0.0-alpha.20200915.1", + "(.NET Core 4.6.29220.03; Microsoft Windows 10.0.18363 )" + ], + "x-ms-client-request-id": "8b3f5a18b6ed1a94de9f4178452b6668", + "x-ms-date": "Tue, 15 Sep 2020 16:44:25 GMT", + "x-ms-return-client-request-id": "true", + "x-ms-version": "2019-02-02" + }, + "RequestBody": { + "PartitionKey": "somPartition", + "RowKey": "01", + "SomeStringProperty": "This is table entity number 01", + "SomeDateProperty": "2020-01-01T01:02:00.0000000Z", + "SomeDateProperty@odata.type": "Edm.DateTime", + "SomeGuidProperty": "0d391d16-97f1-4b9a-be68-4cc871f90001", + "SomeGuidProperty@odata.type": "Edm.Guid", + "SomeBinaryProperty": "AQIDBAU=", + "SomeBinaryProperty@odata.type": "Edm.Binary", + "SomeInt64Property": "1", + "SomeInt64Property@odata.type": "Edm.Int64", + "SomeDoubleProperty0": 1, + "SomeDoubleProperty0@odata.type": "Edm.Double", + "SomeDoubleProperty1": 1.1000000000000001, + "SomeDoubleProperty1@odata.type": "Edm.Double", + "SomeIntProperty": 1 + }, + "StatusCode": 204, + "ResponseHeaders": { + "Content-Length": "0", + "Date": "Tue, 15 Sep 2020 16:44:25 GMT", + "ETag": "W/\u0022datetime\u00272020-09-15T16%3A44%3A25.7994760Z\u0027\u0022", + "Location": "https://chrissprim.table.cosmos.azure.com/testtabletat5i3e2(PartitionKey=\u0027somPartition\u0027,RowKey=\u002701\u0027)", + "Preference-Applied": "return-no-content", + "Server": "Microsoft-HTTPAPI/2.0", + "x-ms-request-id": "8b3f5a18-b6ed-1a94-de9f-4178452b6668" + }, + "ResponseBody": [] + }, + { + "RequestUri": "https://chrissprim.table.cosmos.azure.com/testtabletat5i3e2(PartitionKey=\u0027somPartition\u0027,RowKey=\u002701\u0027)?$format=application%2Fjson%3Bodata%3Dminimalmetadata\u0026$select=PartitionKey", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": "application/json", + "Authorization": "Sanitized", + "DataServiceVersion": "3.0", + "traceparent": "00-464bb8b436755549bb86bf67c8f08800-3df34eeca27d7a48-00", + "User-Agent": [ + "azsdk-net-Data.Tables/3.0.0-alpha.20200915.1", + "(.NET Core 4.6.29220.03; Microsoft Windows 10.0.18363 )" + ], + "x-ms-client-request-id": "ce8db308cc4ba9701c33f5e6477c06b9", + "x-ms-date": "Tue, 15 Sep 2020 16:44:26 GMT", + "x-ms-return-client-request-id": "true", + "x-ms-version": "2019-02-02" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Content-Type": "application/json", + "Date": "Tue, 15 Sep 2020 16:44:25 GMT", + "ETag": "W/\u0022datetime\u00272020-09-15T16%3A44%3A25.7994760Z\u0027\u0022", + "Server": "Microsoft-HTTPAPI/2.0", + "Transfer-Encoding": "chunked", + "x-ms-request-id": "ce8db308-cc4b-a970-1c33-f5e6477c06b9" + }, + "ResponseBody": { + "odata.metadata": "https://chrissprim.table.cosmos.azure.com/testtabletat5i3e2/$metadata#testtabletat5i3e2/@Element", + "odata.etag": "W/\u0022datetime\u00272020-09-15T16%3A44%3A25.7994760Z\u0027\u0022", + "PartitionKey": "somPartition" + } + }, + { + "RequestUri": "https://chrissprim.table.cosmos.azure.com/Tables(\u0027testtabletat5i3e2\u0027)", + "RequestMethod": "DELETE", + "RequestHeaders": { + "Accept": "application/json", + "Authorization": "Sanitized", + "traceparent": "00-b95dd0983fcd324a815b9f745705ba15-203bf3d296666d46-00", + "User-Agent": [ + "azsdk-net-Data.Tables/3.0.0-alpha.20200915.1", + "(.NET Core 4.6.29220.03; Microsoft Windows 10.0.18363 )" + ], + "x-ms-client-request-id": "2a6b6067dd1d6eaa7bdc8796407823f4", + "x-ms-date": "Tue, 15 Sep 2020 16:44:26 GMT", + "x-ms-return-client-request-id": "true", + "x-ms-version": "2019-02-02" + }, + "RequestBody": null, + "StatusCode": 204, + "ResponseHeaders": { + "Content-Length": "0", + "Date": "Tue, 15 Sep 2020 16:44:25 GMT", + "Server": "Microsoft-HTTPAPI/2.0", + "x-ms-request-id": "2a6b6067-dd1d-6eaa-7bdc-8796407823f4" + }, + "ResponseBody": [] + } + ], + "Variables": { + "COSMOS_TABLES_ENDPOINT_SUFFIX": null, + "RandomSeed": "1443610067", + "TABLES_COSMOS_ACCOUNT_NAME": "chrissprim", + "TABLES_PRIMARY_COSMOS_ACCOUNT_KEY": "Kg==" + } +} \ No newline at end of file diff --git a/sdk/tables/Azure.Data.Tables/tests/SessionRecords/TableClientLiveTests(Storage)/CreateEntityAllowsSelect.json b/sdk/tables/Azure.Data.Tables/tests/SessionRecords/TableClientLiveTests(Storage)/CreateEntityAllowsSelect.json new file mode 100644 index 0000000000000..868d42f267def --- /dev/null +++ b/sdk/tables/Azure.Data.Tables/tests/SessionRecords/TableClientLiveTests(Storage)/CreateEntityAllowsSelect.json @@ -0,0 +1,184 @@ +{ + "Entries": [ + { + "RequestUri": "https://chrissscratch.table.core.windows.net/Tables?$format=application%2Fjson%3Bodata%3Dminimalmetadata", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "application/json", + "Authorization": "Sanitized", + "Content-Length": "33", + "Content-Type": "application/json; odata=nometadata", + "DataServiceVersion": "3.0", + "traceparent": "00-9231a9382ac74c43937323158a453ce1-5f819d015bc2954e-00", + "User-Agent": [ + "azsdk-net-Data.Tables/3.0.0-alpha.20200915.1", + "(.NET Core 4.6.29220.03; Microsoft Windows 10.0.18363 )" + ], + "x-ms-client-request-id": "789b380bf93997f27c5e761366329a0b", + "x-ms-date": "Tue, 15 Sep 2020 16:44:24 GMT", + "x-ms-return-client-request-id": "true", + "x-ms-version": "2019-02-02" + }, + "RequestBody": { + "TableName": "testtablebc3res5j" + }, + "StatusCode": 201, + "ResponseHeaders": { + "Cache-Control": "no-cache", + "Content-Type": "application/json; odata=minimalmetadata; streaming=true; charset=utf-8", + "Date": "Tue, 15 Sep 2020 16:44:24 GMT", + "Location": "https://chrissscratch.table.core.windows.net/Tables(\u0027testtablebc3res5j\u0027)", + "Server": [ + "Windows-Azure-Table/1.0", + "Microsoft-HTTPAPI/2.0" + ], + "Transfer-Encoding": "chunked", + "X-Content-Type-Options": "nosniff", + "x-ms-client-request-id": "789b380bf93997f27c5e761366329a0b", + "x-ms-request-id": "7e8dc1ea-3002-0045-517f-8b1979000000", + "x-ms-version": "2019-02-02" + }, + "ResponseBody": { + "odata.metadata": "https://chrissscratch.table.core.windows.net/$metadata#Tables/@Element", + "TableName": "testtablebc3res5j" + } + }, + { + "RequestUri": "https://chrissscratch.table.core.windows.net/testtablebc3res5j?$format=application%2Fjson%3Bodata%3Dminimalmetadata", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "application/json", + "Authorization": "Sanitized", + "Content-Length": "614", + "Content-Type": "application/json; odata=nometadata", + "DataServiceVersion": "3.0", + "Prefer": "return-no-content", + "traceparent": "00-a61bf34543f062438bf3d5dd93001048-04dd5f029f35f047-00", + "User-Agent": [ + "azsdk-net-Data.Tables/3.0.0-alpha.20200915.1", + "(.NET Core 4.6.29220.03; Microsoft Windows 10.0.18363 )" + ], + "x-ms-client-request-id": "49bd6db31c576decab7fe58ba1380ec3", + "x-ms-date": "Tue, 15 Sep 2020 16:44:25 GMT", + "x-ms-return-client-request-id": "true", + "x-ms-version": "2019-02-02" + }, + "RequestBody": { + "PartitionKey": "somPartition", + "RowKey": "01", + "SomeStringProperty": "This is table entity number 01", + "SomeDateProperty": "2020-01-01T01:02:00.0000000Z", + "SomeDateProperty@odata.type": "Edm.DateTime", + "SomeGuidProperty": "0d391d16-97f1-4b9a-be68-4cc871f90001", + "SomeGuidProperty@odata.type": "Edm.Guid", + "SomeBinaryProperty": "AQIDBAU=", + "SomeBinaryProperty@odata.type": "Edm.Binary", + "SomeInt64Property": "1", + "SomeInt64Property@odata.type": "Edm.Int64", + "SomeDoubleProperty0": 1, + "SomeDoubleProperty0@odata.type": "Edm.Double", + "SomeDoubleProperty1": 1.1000000000000001, + "SomeDoubleProperty1@odata.type": "Edm.Double", + "SomeIntProperty": 1 + }, + "StatusCode": 204, + "ResponseHeaders": { + "Cache-Control": "no-cache", + "Content-Length": "0", + "DataServiceId": "https://chrissscratch.table.core.windows.net/testtablebc3res5j(PartitionKey=\u0027somPartition\u0027,RowKey=\u002701\u0027)", + "Date": "Tue, 15 Sep 2020 16:44:24 GMT", + "ETag": "W/\u0022datetime\u00272020-09-15T16%3A44%3A25.0097559Z\u0027\u0022", + "Location": "https://chrissscratch.table.core.windows.net/testtablebc3res5j(PartitionKey=\u0027somPartition\u0027,RowKey=\u002701\u0027)", + "Preference-Applied": "return-no-content", + "Server": [ + "Windows-Azure-Table/1.0", + "Microsoft-HTTPAPI/2.0" + ], + "X-Content-Type-Options": "nosniff", + "x-ms-client-request-id": "49bd6db31c576decab7fe58ba1380ec3", + "x-ms-request-id": "7e8dc1f2-3002-0045-577f-8b1979000000", + "x-ms-version": "2019-02-02" + }, + "ResponseBody": [] + }, + { + "RequestUri": "https://chrissscratch.table.core.windows.net/testtablebc3res5j(PartitionKey=\u0027somPartition\u0027,RowKey=\u002701\u0027)?$format=application%2Fjson%3Bodata%3Dminimalmetadata\u0026$select=PartitionKey", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": "application/json", + "Authorization": "Sanitized", + "DataServiceVersion": "3.0", + "traceparent": "00-b7a37651fe5dc340acbd73c1c3d6d7de-c05dbae9f5193f42-00", + "User-Agent": [ + "azsdk-net-Data.Tables/3.0.0-alpha.20200915.1", + "(.NET Core 4.6.29220.03; Microsoft Windows 10.0.18363 )" + ], + "x-ms-client-request-id": "476b3ce767658f526fe99d79d4ddcd86", + "x-ms-date": "Tue, 15 Sep 2020 16:44:25 GMT", + "x-ms-return-client-request-id": "true", + "x-ms-version": "2019-02-02" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Cache-Control": "no-cache", + "Content-Type": "application/json; odata=minimalmetadata; streaming=true; charset=utf-8", + "Date": "Tue, 15 Sep 2020 16:44:24 GMT", + "ETag": "W/\u0022datetime\u00272020-09-15T16%3A44%3A25.0097559Z\u0027\u0022", + "Server": [ + "Windows-Azure-Table/1.0", + "Microsoft-HTTPAPI/2.0" + ], + "Transfer-Encoding": "chunked", + "X-Content-Type-Options": "nosniff", + "x-ms-client-request-id": "476b3ce767658f526fe99d79d4ddcd86", + "x-ms-request-id": "7e8dc1f7-3002-0045-5c7f-8b1979000000", + "x-ms-version": "2019-02-02" + }, + "ResponseBody": { + "odata.metadata": "https://chrissscratch.table.core.windows.net/$metadata#testtablebc3res5j/@Element\u0026$select=PartitionKey", + "odata.etag": "W/\u0022datetime\u00272020-09-15T16%3A44%3A25.0097559Z\u0027\u0022", + "PartitionKey": "somPartition" + } + }, + { + "RequestUri": "https://chrissscratch.table.core.windows.net/Tables(\u0027testtablebc3res5j\u0027)", + "RequestMethod": "DELETE", + "RequestHeaders": { + "Accept": "application/json", + "Authorization": "Sanitized", + "traceparent": "00-cca7d86ff6426f47af9c64a9dd734319-d0fd69035230414c-00", + "User-Agent": [ + "azsdk-net-Data.Tables/3.0.0-alpha.20200915.1", + "(.NET Core 4.6.29220.03; Microsoft Windows 10.0.18363 )" + ], + "x-ms-client-request-id": "ece02824fb21ef804c2eccba1466f643", + "x-ms-date": "Tue, 15 Sep 2020 16:44:25 GMT", + "x-ms-return-client-request-id": "true", + "x-ms-version": "2019-02-02" + }, + "RequestBody": null, + "StatusCode": 204, + "ResponseHeaders": { + "Cache-Control": "no-cache", + "Content-Length": "0", + "Date": "Tue, 15 Sep 2020 16:44:24 GMT", + "Server": [ + "Windows-Azure-Table/1.0", + "Microsoft-HTTPAPI/2.0" + ], + "X-Content-Type-Options": "nosniff", + "x-ms-client-request-id": "ece02824fb21ef804c2eccba1466f643", + "x-ms-request-id": "7e8dc203-3002-0045-667f-8b1979000000", + "x-ms-version": "2019-02-02" + }, + "ResponseBody": [] + } + ], + "Variables": { + "RandomSeed": "658027762", + "STORAGE_ENDPOINT_SUFFIX": null, + "TABLES_PRIMARY_STORAGE_ACCOUNT_KEY": "Kg==", + "TABLES_STORAGE_ACCOUNT_NAME": "chrissscratch" + } +} \ No newline at end of file diff --git a/sdk/tables/Azure.Data.Tables/tests/SessionRecords/TableClientLiveTests(Storage)/CreateEntityAllowsSelectAsync.json b/sdk/tables/Azure.Data.Tables/tests/SessionRecords/TableClientLiveTests(Storage)/CreateEntityAllowsSelectAsync.json new file mode 100644 index 0000000000000..ac3590969dc41 --- /dev/null +++ b/sdk/tables/Azure.Data.Tables/tests/SessionRecords/TableClientLiveTests(Storage)/CreateEntityAllowsSelectAsync.json @@ -0,0 +1,184 @@ +{ + "Entries": [ + { + "RequestUri": "https://chrissscratch.table.core.windows.net/Tables?$format=application%2Fjson%3Bodata%3Dminimalmetadata", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "application/json", + "Authorization": "Sanitized", + "Content-Length": "33", + "Content-Type": "application/json; odata=nometadata", + "DataServiceVersion": "3.0", + "traceparent": "00-043427dc8afd0b4bb107f7a51a3752e9-dc1ff7ebff36ac4d-00", + "User-Agent": [ + "azsdk-net-Data.Tables/3.0.0-alpha.20200915.1", + "(.NET Core 4.6.29220.03; Microsoft Windows 10.0.18363 )" + ], + "x-ms-client-request-id": "472a487ff610f5f87f80db239fb46a7a", + "x-ms-date": "Tue, 15 Sep 2020 16:44:26 GMT", + "x-ms-return-client-request-id": "true", + "x-ms-version": "2019-02-02" + }, + "RequestBody": { + "TableName": "testtablebxehqirs" + }, + "StatusCode": 201, + "ResponseHeaders": { + "Cache-Control": "no-cache", + "Content-Type": "application/json; odata=minimalmetadata; streaming=true; charset=utf-8", + "Date": "Tue, 15 Sep 2020 16:44:25 GMT", + "Location": "https://chrissscratch.table.core.windows.net/Tables(\u0027testtablebxehqirs\u0027)", + "Server": [ + "Windows-Azure-Table/1.0", + "Microsoft-HTTPAPI/2.0" + ], + "Transfer-Encoding": "chunked", + "X-Content-Type-Options": "nosniff", + "x-ms-client-request-id": "472a487ff610f5f87f80db239fb46a7a", + "x-ms-request-id": "7e8dc354-3002-0045-317f-8b1979000000", + "x-ms-version": "2019-02-02" + }, + "ResponseBody": { + "odata.metadata": "https://chrissscratch.table.core.windows.net/$metadata#Tables/@Element", + "TableName": "testtablebxehqirs" + } + }, + { + "RequestUri": "https://chrissscratch.table.core.windows.net/testtablebxehqirs?$format=application%2Fjson%3Bodata%3Dminimalmetadata", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "application/json", + "Authorization": "Sanitized", + "Content-Length": "614", + "Content-Type": "application/json; odata=nometadata", + "DataServiceVersion": "3.0", + "Prefer": "return-no-content", + "traceparent": "00-4815d4ca8d72354493c067c2c8d38c51-2a6e963ee8ede44a-00", + "User-Agent": [ + "azsdk-net-Data.Tables/3.0.0-alpha.20200915.1", + "(.NET Core 4.6.29220.03; Microsoft Windows 10.0.18363 )" + ], + "x-ms-client-request-id": "98919f1b8ee0f118b0aa0963694a754d", + "x-ms-date": "Tue, 15 Sep 2020 16:44:26 GMT", + "x-ms-return-client-request-id": "true", + "x-ms-version": "2019-02-02" + }, + "RequestBody": { + "PartitionKey": "somPartition", + "RowKey": "01", + "SomeStringProperty": "This is table entity number 01", + "SomeDateProperty": "2020-01-01T01:02:00.0000000Z", + "SomeDateProperty@odata.type": "Edm.DateTime", + "SomeGuidProperty": "0d391d16-97f1-4b9a-be68-4cc871f90001", + "SomeGuidProperty@odata.type": "Edm.Guid", + "SomeBinaryProperty": "AQIDBAU=", + "SomeBinaryProperty@odata.type": "Edm.Binary", + "SomeInt64Property": "1", + "SomeInt64Property@odata.type": "Edm.Int64", + "SomeDoubleProperty0": 1, + "SomeDoubleProperty0@odata.type": "Edm.Double", + "SomeDoubleProperty1": 1.1000000000000001, + "SomeDoubleProperty1@odata.type": "Edm.Double", + "SomeIntProperty": 1 + }, + "StatusCode": 204, + "ResponseHeaders": { + "Cache-Control": "no-cache", + "Content-Length": "0", + "DataServiceId": "https://chrissscratch.table.core.windows.net/testtablebxehqirs(PartitionKey=\u0027somPartition\u0027,RowKey=\u002701\u0027)", + "Date": "Tue, 15 Sep 2020 16:44:25 GMT", + "ETag": "W/\u0022datetime\u00272020-09-15T16%3A44%3A26.3768994Z\u0027\u0022", + "Location": "https://chrissscratch.table.core.windows.net/testtablebxehqirs(PartitionKey=\u0027somPartition\u0027,RowKey=\u002701\u0027)", + "Preference-Applied": "return-no-content", + "Server": [ + "Windows-Azure-Table/1.0", + "Microsoft-HTTPAPI/2.0" + ], + "X-Content-Type-Options": "nosniff", + "x-ms-client-request-id": "98919f1b8ee0f118b0aa0963694a754d", + "x-ms-request-id": "7e8dc38e-3002-0045-687f-8b1979000000", + "x-ms-version": "2019-02-02" + }, + "ResponseBody": [] + }, + { + "RequestUri": "https://chrissscratch.table.core.windows.net/testtablebxehqirs(PartitionKey=\u0027somPartition\u0027,RowKey=\u002701\u0027)?$format=application%2Fjson%3Bodata%3Dminimalmetadata\u0026$select=PartitionKey", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": "application/json", + "Authorization": "Sanitized", + "DataServiceVersion": "3.0", + "traceparent": "00-5fc2ab0bd8f0c147aced1371e80fccbc-72baff5a98701949-00", + "User-Agent": [ + "azsdk-net-Data.Tables/3.0.0-alpha.20200915.1", + "(.NET Core 4.6.29220.03; Microsoft Windows 10.0.18363 )" + ], + "x-ms-client-request-id": "6a8665a9d02186a630cf24db4bb220a3", + "x-ms-date": "Tue, 15 Sep 2020 16:44:26 GMT", + "x-ms-return-client-request-id": "true", + "x-ms-version": "2019-02-02" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Cache-Control": "no-cache", + "Content-Type": "application/json; odata=minimalmetadata; streaming=true; charset=utf-8", + "Date": "Tue, 15 Sep 2020 16:44:26 GMT", + "ETag": "W/\u0022datetime\u00272020-09-15T16%3A44%3A26.3768994Z\u0027\u0022", + "Server": [ + "Windows-Azure-Table/1.0", + "Microsoft-HTTPAPI/2.0" + ], + "Transfer-Encoding": "chunked", + "X-Content-Type-Options": "nosniff", + "x-ms-client-request-id": "6a8665a9d02186a630cf24db4bb220a3", + "x-ms-request-id": "7e8dc3dc-3002-0045-357f-8b1979000000", + "x-ms-version": "2019-02-02" + }, + "ResponseBody": { + "odata.metadata": "https://chrissscratch.table.core.windows.net/$metadata#testtablebxehqirs/@Element\u0026$select=PartitionKey", + "odata.etag": "W/\u0022datetime\u00272020-09-15T16%3A44%3A26.3768994Z\u0027\u0022", + "PartitionKey": "somPartition" + } + }, + { + "RequestUri": "https://chrissscratch.table.core.windows.net/Tables(\u0027testtablebxehqirs\u0027)", + "RequestMethod": "DELETE", + "RequestHeaders": { + "Accept": "application/json", + "Authorization": "Sanitized", + "traceparent": "00-944f298a52d4b84bbc33721ff67707ce-5bef5f84b4caad42-00", + "User-Agent": [ + "azsdk-net-Data.Tables/3.0.0-alpha.20200915.1", + "(.NET Core 4.6.29220.03; Microsoft Windows 10.0.18363 )" + ], + "x-ms-client-request-id": "d26cf191a290f0cf2f399665ed948c34", + "x-ms-date": "Tue, 15 Sep 2020 16:44:26 GMT", + "x-ms-return-client-request-id": "true", + "x-ms-version": "2019-02-02" + }, + "RequestBody": null, + "StatusCode": 204, + "ResponseHeaders": { + "Cache-Control": "no-cache", + "Content-Length": "0", + "Date": "Tue, 15 Sep 2020 16:44:26 GMT", + "Server": [ + "Windows-Azure-Table/1.0", + "Microsoft-HTTPAPI/2.0" + ], + "X-Content-Type-Options": "nosniff", + "x-ms-client-request-id": "d26cf191a290f0cf2f399665ed948c34", + "x-ms-request-id": "7e8dc3e5-3002-0045-3e7f-8b1979000000", + "x-ms-version": "2019-02-02" + }, + "ResponseBody": [] + } + ], + "Variables": { + "RandomSeed": "285417219", + "STORAGE_ENDPOINT_SUFFIX": null, + "TABLES_PRIMARY_STORAGE_ACCOUNT_KEY": "Kg==", + "TABLES_STORAGE_ACCOUNT_NAME": "chrissscratch" + } +} \ No newline at end of file diff --git a/sdk/tables/Azure.Data.Tables/tests/TableClientLiveTests.cs b/sdk/tables/Azure.Data.Tables/tests/TableClientLiveTests.cs index e996e3a2d6de2..5e38d1b2c84f5 100644 --- a/sdk/tables/Azure.Data.Tables/tests/TableClientLiveTests.cs +++ b/sdk/tables/Azure.Data.Tables/tests/TableClientLiveTests.cs @@ -543,9 +543,35 @@ public async Task CreateEntityReturnsEntitiesWithoutOdataAnnoations() // Create an entity. await client.AddEntityAsync(entityToCreate).ConfigureAwait(false); - TableEntity createdEntity = await client.GetEntityAsync(entityToCreate.PartitionKey, entityToCreate.RowKey).ConfigureAwait(false); + TableEntity entity = await client.GetEntityAsync(entityToCreate.PartitionKey, entityToCreate.RowKey).ConfigureAwait(false); - Assert.That(createdEntity.Keys.Count(k => k.EndsWith(TableConstants.Odata.OdataTypeString)), Is.Zero, "The entity should not containt any odata data annotation properties"); + Assert.That(entity.Keys.Count(k => k.EndsWith(TableConstants.Odata.OdataTypeString)), Is.Zero, "The entity should not containt any odata data annotation properties"); + } + + /// + /// Validates the functionality of the TableClient. + /// + [RecordedTest] + public async Task CreateEntityAllowsSelect() + { + TableEntity entityToCreate = CreateTableEntities(PartitionKeyValue, 1).First(); + + // Create an entity. + + await client.AddEntityAsync(entityToCreate).ConfigureAwait(false); + TableEntity entity = await client.GetEntityAsync(entityToCreate.PartitionKey, entityToCreate.RowKey, new[] { nameof(entityToCreate.PartitionKey) }).ConfigureAwait(false); + + Assert.That(entity.PartitionKey, Is.EqualTo(entityToCreate.PartitionKey), "The entity property should be equal"); + Assert.That(entity.RowKey, Is.Null, "The entity property should be null"); + Assert.That(entity.Timestamp, Is.Null, "The entity property should be null"); + Assert.That(entity.TryGetValue(StringTypePropertyName, out _), Is.False, "The entity property should not exist"); + Assert.That(entity.TryGetValue(DateTypePropertyName, out _), Is.False, "The entity property should not exist"); + Assert.That(entity.TryGetValue(GuidTypePropertyName, out _), Is.False, "The entity property should not exist"); + Assert.That(entity.TryGetValue(BinaryTypePropertyName, out _), Is.False, "The entity property should not exist"); + Assert.That(entity.TryGetValue(Int64TypePropertyName, out _), Is.False, "The entity property should not exist"); + Assert.That(entity.TryGetValue(DoubleTypePropertyName, out _), Is.False, "The entity property should not exist"); + Assert.That(entity.TryGetValue(DoubleDecimalTypePropertyName, out _), Is.False, "The entity property should not exist"); + Assert.That(entity.TryGetValue(IntTypePropertyName, out _), Is.False, "The entity property should not exist"); } ///