title: Wrapping a Web API response in JSON but still having it work with IQueryable and oData
body: <p>I have an ASP.NET Web API project, and I want to use oData filters in the project, with the ASP.NET oData preview package. This means I need to use <code>IQueryable</code> as the response type.</p>
  
  <p>Unfortunately, the consumer requires the response wrapped like so:</p>
  
  <pre><code>{
     "total": 2,
     "success": true,
     "data": [ 
             { object1 },
             { object2 } ]
  }
  </code></pre>
  
  <p>I created a wrapper object which assigns the <code>IQueryable</code> response from my original version to the "data" property, and sets the values for the "total" and "success" properties as well. This creates the JSON response the consumer is looking for. But it's no longer IQueryable, which means I can't implement oData filters.</p>
  
  <p>I was hoping to take my wrapper object and make it implement IQueryable by setting its enumerators, etc. However, I don't think this will work because I have to assign the Provider and Expression properties to implement the interface, and I don't know what I should put there. I'm using a Repository pattern with IoC, and the EntityFramework Code First data access is in a separate project, with concrete objects assigned to the interface placeholders using Ninject. Perhaps I can abstract out the interfaces all the way from the data access layer so that the the Repository objects carry a reference to an IQueryProvider. Do you think this would work, and allow it to support the automated oData integration?</p>