I'm playing around with the WebAPI beta, and it seems that selects have no effect on the response of an action returning an IQueryable. Eg:
http://localhost:62689/api/product?$select=Id,Name
Expected:
<Product>
<Id>1</Id>
<Name>Product 1</Name>
</Product>
Actual result:
<Product>
<Id>1</Id>
<Name>Product 1</Name>
<ItemsInStock>6</ItemsInStock>
<Price>49.99</Price>
<Created>2012-01-15T00:00:00</Created>
</Product>
Are there limitations on OData support for WebAPI?
I've tried other queries on this set of data (like top, filter) and they work fine.
In Solution Explorer, right click on Models folder > Add > Class > Name your class. Now, we are going to create a Controller. Right click on the Controllers folder > Add > Controller> selecting Web API 2 OData v3 Controller with actions, using Entity Framework > click Add.
The following are the OData query options that ASP.NET WebAPI supports, $orderby: Sorts the fetched record in particular order like ascending or descending. $select: Selects the columns or properties in the result set.
The Web API does not support the OData $select query.
The current support of query string parameters is limited to $top, $skip, $filter and $orderby.
Take a look at this forum post for more details.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With