Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Azure Table Storage: Ignoring a property of a TableEntity when using the Azure.Data.Tables package

I am using the new Azure.Data.Tables library from Microsoft to deal with Azure Table Storage. With the old library when you had an entity that implemented ITableEntity and you had a property that you did not want to save to the storage table you would use the [IgnoreProperty] annotation. However, this does not seem to be available on the new library.

What would be the equivalent on the Azure.Data.Tables package or how do you now avoid saving a property to table storage now?

This is the class I want to persist:

public class MySpatialEntity : ITableEntity
{
    public int ObjectId { get; set; }
    public string Name { get; set; }
    public int MonitoringArea { get; set; }

    //This is the property I want to ignore because table storage cannot store it
    public Point Geometry { get; set; }

    //ITableEntity Members
    public virtual string PartitionKey { get => MonitoringArea.ToString(); set => MonitoringArea = int.Parse(value); }
    public virtual string RowKey { get => ObjectId.ToString(); set => ObjectId = int.Parse(value); }
    public DateTimeOffset? Timestamp { get; set; }
    public ETag ETag { get; set; }
}
like image 825
paddingtonMike Avatar asked Feb 01 '26 08:02

paddingtonMike


1 Answers

As of version 12.2.0.beta.1, Azure.Data.Tables table entity models now support ignoring properties during serialization via the [IgnoreDataMember] attribute and renaming properties via the [DataMember(Name="<yourNameHere>")] attribute.

See the changelog here.

like image 73
Christopher Scott Avatar answered Feb 04 '26 01:02

Christopher Scott