WCF: DataMember attribute on property vs. member

后端 未结 7 2002
北海茫月
北海茫月 2021-01-30 20:27

In wcf, what is the difference between applying the DataMember attribute on a property

private int m_SomeValue;

[DataMember]  
public int SomeVal         


        
相关标签:
7条回答
  • 2021-01-30 21:03

    There are good reasons you may want to mark fields rather than properties as DataMember .

    Please check this for more details : http://blog.walteralmeida.com/2010/05/wcf-and-datacontract-serialization-internals-and-tips-.html

    By the way: ContractSerializers will serialize any private field that has the DataMemberAttribute on it only if running in full trust environment. Does not work in partial trust (check the blog listed above for a solution)

    0 讨论(0)
提交回复
热议问题