Firstly:
public Dimensions()
{
_cEmployees = new List<employee>();
}
This looks like a constructor but the method name doesn't match the class name?
Also, not sure you'd want a private member to be a
DataMember
?
[DataMember]
private List _cEmployees = null;
Ideally all
DataMember
's should be properties and not variables. Try this:
[DataContract]
[KnownType(typeof(Employee))]
public class Employees
{
private List<employee> _cEmployees = null;
[DataMember]
public List<employee> EmployeeList
{
get { return _cEmployees; }
set { _cEmployees = value; }
}
public Employees()
{
_cEmployees = new List<employee>();
}
public long Add(Employee Emp)
{
_cEmployees .Add(Emp);
return _cEmployees .Count;
}
}
Although if you're simply returning a collection why bother with the
Employees
class at all?
WCF handles collections all on it's own without the need for a wrapper.