我无法在WCF中返回dataTable,我不知道缺少什么: 我的IService1.cs有:
ServiceContract]
public interface IService1
{
[OperationContract]
UserClass ReturnUser(string Username);
}
[DataContract]
public class Users
{
private myDataSet1.tblUserDataTable dataTable;
[DataMember]
public myDataSet1.tblUserDataTable tblUser
{
get { return dataTable; }
set { dataTable= value; }
}
我的Service1.svc.cs文件有:
CenoppmUser emp = new CenoppmUser();
myDataSet1.tblUserDataTable userTable = new myDataSet1.tblUserDataTable();
myDataSet1TableAdapters.tblUserTableAdapter adapter = new myDataSet1TableAdapters.tblUserTableAdapter();
public Users ReturnUsers(String txtUserName)
{
userTable = adapter.IsUsernameValid(txtUserName);
if (userTable == null)
{
throw new ArgumentNullException("dataTable is null");
}
else
{
if (userTable.Rows.Count != 0)
{
myDataSet1.tblUserRow dataRow = userTable[0];
emp.tblUser = userTable;
emp.Name = dataRow.txtFirstName + " " + dataRow.txtLastName;
}
}
//this is still being returned as null, i want the userTable values.
return emp;
}
返回emp;仍然被返回为null,我想要userTable值。
请帮忙, 感谢