It is because you cannot share DataRow objects. They are not serializable. If you want to share it, you should create DTO objects. It is a good pratice of shareing objects from services, APIs, etc. Tru to convert your DataRow to a DTO object. Try something like:
Create your class to be this DTO, for sample:
[Serializable]
public class UserDTO
{
public string FirstName { get; set; }
public string LastName { get; set; }
public string Address { get; set; }
public string Birthday { get; set; }
/* other properties you need */
}
And in your web api, try this:
public class UserController : ApiController {
public IEnumerable<UserDTO> GetAllUsers() {
GWDataSet gw = new GWDataSet();
usersTableAdapter adapter = new usersTableAdapter();
adapter.Fill(gw.users);
List<UserDTO> list = new List<UserDTO>();
foreach(DataRow row in gw.users.Rows)
{
UserDTO user = new UserDTO();
user.FirstName = row["Name"].ToString();
// fill properties
list.Add(user);
}
return list;
}
}