IT:AD:ASP.NET:WebAPI:HowTo:OData:Install
Process
- Create a Controller:
- That inherits from
System.Web.OData.ODataController - Whose GET method returns an
IQueryableorIHttpActionResult - Whose class – or specific method – is decorated with using
[EnableQuery]
Use
The key part is to inherit from ODataController:
namespace Demo.Controllers
{
[EnableQuery]
public class FooController : ODataController
{
public IHttpActionResult Get()
{
return Ok(FooService.Items.AsQueryable());
}
}
}