したがって、次のように、WebApi Get メソッドで使用するためにSubscription
Azure のクラスから継承するモデルがあります。TableEntity
[HttpGet]
public IEnumerable<Subscription> Subscribers()
このメソッドではSelect
、サブスクライバー テーブルに対してクエリを実行してすべてのサブスクライバーを検索しますが、次のようにいくつかの列 (プロパティ) のみを返したいと考えています。
var query = new TableQuery<Subscription>().Select(new string[] {
"PartitionKey",
"RowKey",
"Description",
"Verified"
});
モデルの定義は次のとおりです。
public class Subscription : TableEntity
{
[Required]
[RegularExpression(@"[\w]+",
ErrorMessage = @"Only alphanumeric characters and underscore (_) are allowed.")]
[Display(Name = "Application Name")]
public string ApplicationName
{
get
{
return this.PartitionKey;
}
set
{
this.PartitionKey = value;
}
}
[Required]
[RegularExpression(@"[\w]+",
ErrorMessage = @"Only alphanumeric characters and underscore (_) are allowed.")]
[Display(Name = "Log Name")]
public string LogName
{
get
{
return this.RowKey;
}
set
{
this.RowKey = value;
}
}
[Required]
[EmailAddressAttribute]
[Display(Name = "Email Address")]
public string EmailAddress { get; set; }
public string Description { get; set; }
public string SubscriberGUID { get; set; }
public bool? Verified { get; set; }
}
以下は、API クエリの XML 応答です。
<ArrayOfSubscription>
<Subscription>
<ETag>W/"datetime'2013-03-18T08%3A54%3A32.483Z'"</ETag>
<PartitionKey>AppName1</PartitionKey><RowKey>Log1</RowKey>
<Timestamp>
<d3p1:DateTime>2013-03-18T08:54:32.483Z</d3p1:DateTime>
<d3p1:OffsetMinutes>0</d3p1:OffsetMinutes>
</Timestamp>
<ApplicationName>AppName1</ApplicationName>
<Description>Desc</Description>
<EmailAddress i:nil="true"/>
<LogName>Log1</LogName>
<SubscriberGUID i:nil="true"/>
<Verified>false</Verified>
</Subscription>
</ArrayOfSubscription>
ご覧のとおり、モデルSubscriberGUID
には、応答でシリアル化したくないなどの追加のプロパティがいくつかあるだけでなく (それらは選択クエリに含まれていないため、いずれにせよ null です)、TableEntity 自体にも次のようなフィールドがあります。 as PartitionKey
、RowKey
、Etag
、Timestamp
も連載中です。
Azure テーブルを引き続き使用しながら、ユーザーに見せたくないこれらの望ましくないフィールドを応答でシリアル化しないようにするにはどうすればよいですか。