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

Jar*_*rde 1 azure nosql azure-storage

鉴于以下课程

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;
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

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

我尝试使用NotMapped属性,但是在这种情况下似乎不起作用。有任何想法吗?

Jar*_*rde 5

我找到了。风景名胜

Microsoft.WindowsAzure.Storage.Table
Run Code Online (Sandbox Code Playgroud)

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

IgnorePropertyAttribute
Run Code Online (Sandbox Code Playgroud)