如何告诉 Azure Table 存储不存储某些实体属性

How to tell Azure Table Storage to not store certain entity properties

鉴于以下 class

public class Account : TableEntity
{
    public Account()
    {

    }
    public Account(string customerName, string username)
    {
        PartitionKey = customerName;
        RowKey = username;
    }

    public string FullName { get; set; }

    public string CustomerName
    {
        get
        {
            return PartitionKey;
        }
        set
        {
            PartitionKey = value;
        }
    }

    public string UserName
    {
        get
        {
            return RowKey;
        }
        set
        {
            RowKey = value;
        }
    }
}

如您所见,我添加了 2 个包装 RowKey 和 PartitionKey 的属性,以便在我的代码库中提高可读性和便利性。问题是这些属性也存储在我的 Table Azure 存储中,这不是我想要的。

我尝试使用 NotMapped 属性,但这似乎不适用于这种情况。有什么想法吗?

我找到了。命名空间

Microsoft.WindowsAzure.Storage.Table

包含一个属性,使您可以在将实体保存到 Table 存储时跳过属性。叫做

IgnorePropertyAttribute