Wrapping a Web API response in JSON but still having it work with IQueryable and oData
问题 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 IQueryable as the response type. Unfortunately, the consumer requires the response wrapped like so: { "total": 2, "success": true, "data": [ { object1 }, { object2 } ] } I created a wrapper object which assigns the IQueryable response from my original version to the "data" property, and sets the values for the "total" and "success" properties as