WCF - use [DataContract] or not with .NET 3.5 SP1?

I work with WCF.NET 3.5 SP1 and read that you DO NOT need to decorate your objects / collections with things like [DataMember], [DataConract] and / or [Serializable]? What is the best way? What are you facing?

I'm on 3.5 SP1.

+3
source share
2 answers

See Using Data Contracts .

The new complex types that you create must have a data contract defined for them to be serializable. By default, it DataContractSerializerdisplays the data for the contract and serializes all publicly visible types. All public read / write properties and type fields are serialized. You can opt out of serialization by using IgnoreDataMemberAttribute. You can also explicitly create a data contract using DataContractAttributeand DataMemberAttribute. This is usually done by applying DataContractAttributethe type attribute. This attribute can be applied to classes, structures, and enumerations. The attribute DataMemberAttributeshould then be applied to each data member to indicate that it is a data member, that is, it should be serialized. For more information, see Serializable Types .

@Terry, , , . , , , .

+6

, DataContract. , , , - DataContract SP1...:)

+1

Source: https://habr.com/ru/post/1711762/


All Articles