0

Want to understand how returning or accepting a normal class as input parameter is different than a DataContract class.

I have class like following

public Employee 
{

    public string empName {get;set;}
}

and my WCF service is like following

[ServiceContract]
public interface IEmployeeService
{

    [OperationContract]
    Employee GetEmployeeDetails(int EmpId);
}

how Employee class is different than following

[DataContract]
public class Employee
{

    [DataMember]
    public string empName {get;set;}
}
Tim
  • 28,212
  • 8
  • 63
  • 76

1 Answers1

0

Not sure I understand the question, but I'll try answering. Marking the class with DataContract and its members with DataMember used to allow any consuming clients to reference and utilize the class. Without those attributes, you couldn't reference the Employee class in the service from any client. *Note that as of .NET 3.5 SP1, you no longer have to tag everything with these attributes, but there are some caveats that you should be aware of. See this post for more information:

When to use DataContract and DataMember attributes?

Community
  • 1
  • 1
Ageonix
  • 1,748
  • 2
  • 19
  • 32