title: ASP.NET Controller with DataRow
body: <p>I'm building a simple ASP.NET application that communicates with a SQL server database. In a separate project, I have the dataset that was generated by Visual Studio. I'm trying to expose an API that will display all users in the database, but I'm getting an exception.</p>
  
  <p>Here is the code:</p>
  
  <pre><code>public class UserController : ApiController {
  
      public IEnumerable&lt;GWDataSet.usersRow&gt; GetAllUsers() {
          GWDataSet gw = new GWDataSet();
          usersTableAdapter adapter = new usersTableAdapter();
          adapter.Fill(gw.users);
  
          return gw.users.AsEnumerable();
      }
  }
  </code></pre>
  
  <p>And this is the exception:</p>
  
  <pre><code>Type 'System.Data.DataRow' cannot be serialized. Consider marking it with the DataContractAttribute attribute, and marking all of its members you want serialized with the DataMemberAttribute attribute. If the type is a collection, consider marking it with the CollectionDataContractAttribute. See the Microsoft .NET Framework documentation for other supported types.
  </code></pre>
  
  <p>Is there a way around this, other than to manually edit the system-generated code? My fear is that next time I make a change to the dataset, it will overwrite all the datacontract elements I add in. I would think there's a way to do this, but I can't seem to find it.</p>
  
  <p>Thanks!</p>