Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you exclude a property from being persisted in Azure Table storage?

If I have a class like this:

    public class Facet : TableServiceEntity {     public Guid ParentId { get; set; }           public string Name { get; set; }     public string Uri{ get; set; }     public Facet Parent { get; set; } } 

Parent is derived from the ParentId Guid, and that relationship is intended to be filled in by my repository. So how do I tell Azure to leave that field alone? Is there an Ignore attribute of some type, or do I have to create an inherited class that provides those relationships instead?

like image 388
Jeff D Avatar asked Feb 16 '10 23:02

Jeff D


People also ask

Is Azure table storage persistent?

Azure Blob Storage TiersThe blob storage option is not persistent, as opposed to other Azure storage options like hard disks of Infrastructure-as-a-Service (IAAS) or VMs. As a result, you have to use persistent stores like tiers for long-term storage of files. There are three types of storage tiers.

How do I remove columns from Azure table storage?

you can do the same by using azure storage explorer. You can export the table of choice, delete the property in the CSV file and import it back in new table. drop the existing table and rename the new table to the existing one.


2 Answers

Using latest Microsoft.WindowsAzure.Storage SDK (v6.2.0 and up), the attribute name has changed to IgnorePropertyAttribute :

public class MyEntity : TableEntity {      public string MyProperty { get; set; }       [IgnoreProperty]      public string MyIgnoredProperty { get; set; } } 
like image 53
Thomas Avatar answered Sep 25 '22 10:09

Thomas


There is an attribute called WindowsAzure.Table.Attributes.IgnoreAttribute can be set on the property you want to exclude. Just use:

[Ignore] public string MyProperty { get; set; } 

It is a part of Windows Azure Storage Extensions, which you may download from: https://github.com/dtretyakov/WindowsAzure

or install as a package: https://www.nuget.org/packages/WindowsAzure.StorageExtensions/

The library is MIT licensed.

like image 37
Mandoleen Avatar answered Sep 25 '22 10:09

Mandoleen