'Azure Table Storage: Use existing properties as PartitionKey and RowKey

I have a model where existing fields already fits quite nicely for RowKey and PartitionKey but I don't know how to assign them and not have duplicate data. Consider this example:

public class ClassA : ITableEntity
{
    // My existing fields
    public string Id { get; set; }
    public string Receiver { get; set; }
    public DateTimeOffset? Received { get; set; }

    // ITableEntity fields
    public string PartitionKey { get => Receiver; set => Receiver = value; }
    public string RowKey { get => Id; set => Id = value; }
    public DateTimeOffset? Timestamp { get => Received; set => Received = value; }
    public ETag ETag { get; set; }
}

This works but we get duplicate data as expected. Then I tried to add [IgnoreDataMember] to Id, Receiver and Received but then I cannot query using TableClient.QueryAsync(x => x.Id == "...").

Is there a way I can map the ITableEntity to my exisiting fields so I:

  1. Avoid having duplicate data
  2. Can query using my exisiting fields

I'm using Azure.Data.Tables Version 12.4.0



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source