I'm using WebApi2 and OData. I want add custom action, and use it by GET method
GET /odata/Providers(2)/DoSth
but I dont understand how it works exactly. Here is code for one of my controller:
public class ProvidersController : ODataController
{
private Entities db = new Entities();
// GET: odata/Providers
[Queryable]
public IQueryable<PROVIDER> GetProviders()
{
return db.PROVIDER;
}
//... OTHER GENERATED METHODS
//MY TEST METHOD SHOULD BE inoked: GET /odata/Providers(2)/DoSth
public int DoSth()
{
return 22;
}
}
and WebApiConfigFile:
ODataConventionModelBuilder builder = new ODataConventionModelBuilder();
builder.EntitySet<PROVIDER>("Providers").EntityType.HasKey(o => o.P_ID);
//others entities ...
//my custom action without any parameters, returns int:
ActionConfiguration getTest = builder.Entity<PROVIDER>().Action("DoSth");
getTest.Returns<int>();
Method existing in /odata/$metadata
but cant run this method from the url (still showing 404: "No HTTP resource was found that matches the request URI").
Any ideas how to improve this issue?