在ServiceStack服务请求和响应DTO中隐藏一些公共属性

Rag*_*eer 2 c# servicestack

我正在使用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
}
Run Code Online (Sandbox Code Playgroud)

从上面的FooResponse,我不想显示PaymentAmount response/metadata.

如果我们将它作为普通变量而不是属性,它将在元数据中不可见.但这应该是其他要求的财产.

是否可以ServiceStack在响应DTO中限制某些属性?

Mar*_* N. 5

使用IgnoreDataMember属性上的PaymentAmount属性.上次我检查ServiceStack正在使用并遵守默认的.NET序列化属性.