Enabling OData Queries in Web API

Enabling OData Queries in Web API

Add EnableQuery Attribute (Action filter)

Change the IEnumerable return type to IQueryable

Add AsQueryable() to convert the IEnumerable to an IQueryable

[EnableQuery()]

public IQueryable<Product> Get()

{

var productRepository=new ProductRepository();

return productRepositriy.Retrieve().AsQueryable();

}