asp.net mvc - How to create custom function on OData RESTier -


i'm referring http://odata.github.io/restier/#03-01-operations on how create custom method takes in input , return list of object.

here's custom method

[httpget] [odataroute("locations/pointloc.data.getlocationsbymarketid()")] public ihttpactionresult getlocationsbymarketid() {     var database = new database();     var locations = database.locations.getalllocationsbymarket(1);     return ok(locations); } 

and here's how set in dbdomain

protected edmmodel onmodelextending(edmmodel model) {     var ns = model.declarednamespaces.first();      var location = model.finddeclaredtype(ns + "." + "location");     var locations = edmcoremodel.getcollection(location.getedmtypereference(isnullable: false));      var getlocationswithmarketid = new edmfunction(ns, "getlocationswithmarketid", locations, true, null, false);     getlocationswithmarketid.addparameter("bindingparameter", locations);     model.addelement(getlocationswithmarketid);      return model; } 

can't work. keep getting odata uri error like

'locations/pointloc.data.getlocationsbymarketid()' on action 'getlocationsbymarketid' in controller 'pointloc' not valid odata path template. request uri not valid. since segment 'locations' refers collection, must last segment in request uri or must followed function or action can bound otherwise intermediate segments must refer single resource.

wanted access odata via "/locations/getlocationsbymarketid". how it?


Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -