What is data contract equivalence?

 Posted by Sgandikota on 7/14/2011 | Category: WCF Interview questions | Views: 5931 | Points: 40
Answer:

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;
}


Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response