Proper way of decorating dto class in wcf communication
.net, c#, wcf
Solution
Actually when you use DataContract metatag, Serializable Metatag do nothing. This is a quote from MSDN article:
With [Serializable], all fields become part of the data contract (unless they are marked with [NonSerialized]). With [DataContract], only members marked with [DataMember] are included. Note that if a type has both [DataContract] and [Serializable] attributes on it, it will use the [DataContract] mapping
http://msdn.microsoft.com/en-us/magazine/cc163569.aspx
KnownType atrribute Marvin described to you in a comment to your question.
Problem
I have class BookDTO which represents object which will be used in exchanging data between client and service where service is wcf service have following attributes ``` [Serializable] [DataContract] [KnownType(typeof(Book))] public class BookDTO {...} ``` Is this proper (standard) way of decorating object which will be send over the wire? I've seen examples with ``` [DataContract(NameSpace="somenamespace.DTO.Book")] ``` Is `[KnownType(typeof(Book))]` redudant here? I've forget to mention that I'm introduced with DataMember attributes, so please disregard that.