Part 6 WCF DataContract and DataMember
>> YOUR LINK HERE: ___ http://youtube.com/watch?v=RPgTKzSGcKY
Link for all dot net and sql server video tutorial playlists • / kudvenkat • Healthy diet is very important both for the body and mind. If you like Aarvi Kitchen recipes, please support by sharing, subscribing and liking our YouTube channel. Hope you can help. • / @aarvikitchen5572 • To understand DataContract and DataMember attributes in WCF, first let's understand what is meant by Serialization. • With respect to WCF, Serialization is the process of converting an object into an XML representation. The reverse process, that is reconstructing the same object from the XML is called as Deserialization. • By default, WCF uses DataContractSerializer. • For a complex type like Customer, Employee, Student to be serialized, the complex type can either be decorated with • 1. SerializableAttribute or • 2. DataContractAttribute • With .NET 3.5 SP1 and above, we don't have to explicitly use DataContract or DataMember attributes. The Data Contract Serializer will serialize all public properties of your complex type in an alphabetical order. By default private field and properties are not serialized. • If we decorate a complex type, with [Serializable] attribute the DataContractSerializer serializes all fields. With [Serializable] attribute we don't have explicit control on what fields to include and exclude in serialized data. • If we decorate a complex type with [Datacontract] attribute, the DataContractSerializer serializes the fields marked with the [DataMember] attribute. The fields that are not marked with [DataMember] attribute are excluded from serialization. The [DataMember] attribute can be applied either on the private fields or public properties. • In WCF, the most common way of serialization is to mark the type with the DataContract attribute and mark each member that needs to be serialized with the DataMember attribute. • If you want to have explicit control on what fields and properties get serialized then use DataContract and DataMember attributes. 1. Using DataContractAttribute, you can define an XML namespace for your data • 2. Using DataMemberAttribute, you can • a) Define Name, Order, and whether if a property or field IsRequired • b) Also, serialize private fields and properties
#############################

New on site