haPartnerships
haPartnerships

Reputation: 385

Azure Table Storage - TableClient not returning ETag

Doing some simple queries using Azure.Data.Table TableClient and the response is not including the ETag.

My entities inherit ITableEntity as required so have the ETag property.

The code is pretty vanilla:

        var tableClient = new TableClient(
        new Uri(storageUri),
        tableName,
        new TableSharedKeyCredential(accountName, storageAccountKey));
        
        var response = await tableClient.GetEntityAsync<TEntity>(partitionKey, rowKey);

        return response.Value;

The output produced is:

{
    "partitionKey": "Partition Key",
    "rowKey": "RowKey",
    "timestamp": "2023-02-07T20:55:45.6532507+00:00",
    "eTag": {},
    "forename": "Forename",
    "surname": "Surname",
    "mobile": "Mobile",
    "address": "Address"
}

I'm at a bit of a loss to think what to do as it is all handled within the TableClient so I can't debug all that much.

Any thoughts much appreciated.

UPDATE

I have modified the code to run using the type <TableEntity> and also for the type <User> which is define as:

public class User : ITableEntity, IResult
{
    public User() { }
    public string PartitionKey { get; set; }
    public string RowKey { get; set; }
    public DateTimeOffset? Timestamp { get; set; }
    public ETag ETag { get; set; }
    public string Forename { get; set; }
    public string Surname { get; set; }
    public string Mobile { get; set; }
    public string Address { get; set; }

}

The TableClient GetEntityAsync methods are respectivly:

 var response = await tableClient.GetEntityAsync<TableEntity>(partitionKey, rowKey);

 var response = await tableClient.GetEntityAsync<User>(partitionKey, rowKey);

The first populates all the fields and the ETag correctly and the latter just populates all of the other fields apart from the ETag.

Dont know if this helps shed some light on what I'm doing wrong?

Upvotes: 0

Views: 349

Answers (0)

Related Questions