title: How do I create an ODataMessageReader from an HttpWebResponse?
body: <p>I am using the <code>Microsoft.Data.OData</code> library and basically want to construct a program which grabs a <code>DataTable</code> out of an OData query, construct a database out of it, and insert the records.</p>
  
  <p>Since this needs to be dynamic, service references are not going to work for me.</p>
  
  <p>After two hours of searching and sifting through documentation on MSDN, I have not yet come up with a solution to my question.</p>
  
  <p>My code so far is below and I just need to know if anyone out there has gotten from an <code>HttpWebRequest</code> to an <code>ODataReader</code> or any relevant class that will let me read the results of the query without writing my own parser and how exactly they did it.</p>
  
  <pre><code>public class ODataPuller
  {
      private readonly Uri uri;
  
      public ODataPuller(Uri uri)
      {
          this.uri = uri;
      }
  
      private async Task&lt;HttpWebResponse&gt; MakeRequestAsync(string filter)
      {
          filter = "?$filter=" + filter;
          Uri target = new Uri(this.uri, filter);
  
          HttpWebRequest request = HttpWebRequest.CreateHttp(target);
          request.Headers["Accept"] = "application/xml";
  
          HttpWebResponse response = await request.GetResponseAsync() as HttpWebResponse;
          return response;
      }
  
      public async Task&lt;DataTable&gt; GetDataTableAsync(string filter)
      {
          HttpWebResponse response = await this.MakeRequestAsync(filter);
  
          Stream stream = response.GetResponseStream();
  
          // Turn this stream into something nice
      }
  }
  </code></pre>