Pages

Men

rh

7/06/2012

What is data contract equivalence?

Two data contracts are said to be equivalent, if they satisfy the following conditions.
- Both the datacontracts must have same namespace
- Both the datacontracts must have same name
- The data member on data contract must have an equivalent data member on the other.
- The members in the datacontract must appear in the same order in both datacontracts.

Ex:

The following two data contracts are equal.
[DataContract]

public class Person
{
    [DataMember]
    public string Name;


    [DataMember]
    public string Email_ID;

}

[DataContract(Name = "Person")]
public class Employee
{
    [DataMember(Name = "Name")]
    private string EmpName;


    private string address;
    [DataMember(Name = "Email_ID")]


    private string EmpEmailId;
}

No comments :

Post a Comment