当强类型的Dataset作为WebService的返回值时,为什么无法把自定义属性也返回?
我做了一个WebService里面有个Web方法,返回一个强类型的datatable(因为这个这个是强类型dataset里面的datatable,定义这个datatable类的时候,添加了Serializable属性标识,因此可以作为WebService的返回值)。这个强类型的dataset下有两个table,分别是Employee(职员)与Department(部门)。我在Employee的datarow类(EmployeeRow)中,添加了一个属性,其类型为一个Department的datarow.即我是想获得一个EmployeeRow对象之后,可以过这个对象的Department属性,可以直接获得他所在的部门的信息。
见如下代码:
public partial class EmployeeRow : global::System.Data.DataRow
{
private DepartmentRow m_drDeportment;
public DepartmentRow Department
{
get { return this.m_drDeportment; }
set { this.m_drDeportment = value; }
}
}
我在本地的程序集中,也可以正常通过EmployeeRow的对象,访问到它的Department属性,当我初始化一个Employee的datatable,并通过WebService返回的时候,发现这个Datatable中的datarow并无Department这个属性,只有字段,有人知道为什么吗?我要怎么做,才能为这个强类型的EmployeeRow添加一个类型是DepartmentRow的属性,且在WebService中可以让它正确返回呢?