[英]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.