[英]Hide some public properties in ServiceStack service Request and Response DTO's
我正在使用ServiceStack構建一些服務,我有以下服務
public class FooRequest: IReturn<FooResponse>
{
public int FooID { get; set; }
public decimal Amount { get; set; }
public string SortColumnName { get; set; }
}
public class FooResponse
{
private List<Payment> payments;
public FooResponse()
{
payments= new List<Payment>();
}
public List<Payment> Payments
{
get { return payments; }
set { payments = value; }
}
}
public class Payment
{
public int ID { get; set; }
public string Amount { get; set; } // Amount is formatted string based on the user language
public decimal PaymentAmount{ get; set; } // this is Alias for Amount
}
在FooResponse上方,我不想在response/metadata
顯示PaymentAmount。
如果我們將其設為普通變量而非屬性,則它在元數據中將不可見。 但這應該是其他要求的屬性。
ServiceStack
是否可以限制響應DTO中的某些屬性?
在IgnoreDataMember
屬性上使用PaymentAmount
屬性。 上一次我檢查ServiceStack是否正在使用並遵守默認的.NET序列化屬性。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.