Search code examples
.netasp.net-mvc-5odata

Can not add function Odata WebAPI controller


I am trying to add a function to an OData controller that merely returns some data. I have followed a few examples and they seem to make use of a

productType.Collection
                .Function("Top10")
                .ReturnsCollectionFromEntitySet<Product>("Products");

Function function. I can't seem to find this anywhere in the OData libraries I have in my application. They indicate here that it should be in the System.Web.OData.Builder but it doesn't seem to be..

Anyone help?


Solution

  • The "Function" only exists in WebAPI odata V4 while V3 only has Action.

    Can you resolve namespace System.Web.OData.Builder?

    If not, you can install nuget package Microsoft.AspNet.WebApi.OData 5.2.0