WCF Datamember返回取决于条件

时间:2014-02-20 02:45:06

标签: vb.net wcf

嗨,我得到了下面的课程,我的问题是想要将ResponseMsg返回给用户只有ResponseCode不是00否则它不会返回给用户。怎么做。请帮忙。感谢

<DataContract([Namespace]:="")>
Public Class LoginResponse
    <DataMember()> _
    Public Property TerminalID As String
    <DataMember()> _
    Public Property ReaderID As String
    <DataMember()> _
    Public Property TransRef As String
    <DataMember()> _
    Public Property TransDateTime As String
    <DataMember()> _
    Public Property Timeout As Integer
    <DataMember()> _
    Public Property ResponseCode As String
    <DataMember()> _
    Public Property ResponseMsg As String
    <DataMember()> _
    Public Property Cryptogram As String
End Class

1 个答案:

答案 0 :(得分:0)

只需为ResponseMsg定义一个属性,如下所示

  Public Property ResponseMsg() As String
     Get
       if String.Compare(ResponseCode , "00") = 0 Then  
         Return m_lWidth
    End Get
    Set(ByVal Value As String)
         m_lWidth = Value
    End Set
  End Property

快乐编码:)