Few things about WCF

Data Contract and Data Member attributes appear in the System.Runtime.Serialization namespace, because they control the general WCF serialization of the object rather than just its xml-serialized version.
The DataContract attribute is applied at the class level and it controls the serialized name of the object as well as the namespace.
The DataMember attribute is applied to the specific properties you want to be included. It allows you to specify the serialized name of the property, the order in which it appears within the object as well as whether or not it is a required attribute
DataMember attribute works independently of the regular scope of the field or property. For instance, a private or internal property could be marked with the attribute and thus made available via a WCF service, even though it was inaccessible from elsewhere within the object hierarchy or client code.

Popular Posts