2015-10-25 46 views
1

考慮下面的類如何分辨Azure的表存儲不存儲某些實體屬性

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在我的代碼庫更多的可讀性和便利。問題是這些屬性也存儲在Azure存儲的表中,這不是我想要的。

我試過使用NotMapped屬性,但似乎不適用於這種情況。有任何想法嗎?

回答

4

我找到了。名稱空間

Microsoft.WindowsAzure.Storage.Table 

包含一個屬性,使您可以在將實體保存到表存儲時跳過屬性。它叫做

IgnorePropertyAttribute