0

I can't return the dataTable in WCF, i don't know what am missing: My IService1.cs has:

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; }

}

My Service1.svc.cs file has:

  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;

    }

The return emp; is still being returned as null, i want the userTable values.

Please help, Thanks

user1179083
  • 79
  • 1
  • 5
  • 17
  • 2
    WCF being an interoperable messaging system should *not* be using .NET specific things like `DataTable` - use proper object classes and collections thereof for your service datatypes! – marc_s Apr 04 '14 at 17:26
  • oh ok, i thought there was a shorter way, cause i have long tables. – user1179083 Apr 07 '14 at 13:23

0 Answers0