A data contract is a formal agreement between a service and a client that abstractly describes the data to be exchanged.
System.Runtime.Serialization Example :
[DataMember] public string Name { get { return m_Name; } set { m_Name = value; }
}
[DataMember] public int Age { get { return m_Age; } set { m_Age = value; } }
[DataMember] public int Salary { get { return m_Salary; } set { m_Salary = value; } }
[DataMember] public string Designation { get { return m_Designation; } set { m_Designation = value; } }
[DataMember] public string Manager { get { return m_Manager; } set { m_Manager = value; } } }In GetCustomerData method we have created the Customer instance and return to the client.As we have created the data contract for the Employee class, client will aware of this instance whenever he creates proxy for the service.
namespace DataContractinWCF.Web
{
public classService1 : IService1
public Cusomer GetCustomerData (int empId)
Cusomer CusDetail = new Cusomer ();
//Do something to get Customer details and assign to CusDetail properties
return CusDetail;
ServiceReference1.Service1Client service = new ServiceReference1.Service1Client();
Cusomer CusDetails;
CusDetails = service.GetCustomerData(CusomerId);
//Do something on Customer details
You need to be a premium member to use this feature. To access it, you'll have to upgrade your membership.
Become a sharper developer and jumpstart your career.
$0
$
. 00
monthly
For Basic members:
$20
For Premium members:
$45
For Elite members: