c# - Handle Odata /entityset/key/navigation -


we have project based on dynamicedmmodelcreation project odatasamples-master odata examples.

we have set routing convention handle request specific controller:

[httpget] [enablequery] public edmentityobjectcollection get() { ... } [enablequery] public iedmentityobject get(string key) { ... } 

we try example

/odata/hotels -> ok!

/odata/hotels(1) -> ok!

/odata/hotels(1)/room -> response:

no routing convention found select action odata path template '~/entityset/key/navigation'.

debuging see route convention handle request , redirect our controller no method executed. routing convention is:

public class matchroutingconventionservice : iodataroutingconvention {     public string selectaction(         odatapath odatapath,         httpcontrollercontext controllercontext,         ilookup<string, httpactiondescriptor> actionmap)     {         return null;     }      public string selectcontroller(odatapath odatapath, httprequestmessage request)     {         return (odatapath.segments.firstordefault() entitysetpathsegment) ? "hamdleall" : null;     } } 

we think problem may in webapi chossing correct method handle request because since using generic signature iedmentityobject get(string key).

in controller, there're 2 methods named get(), get(string key). result is:

  1. /odata/hotels ok because request can route get() method convention.

  2. /odata/hotels(1) ok because request can route get(string key) convention.

however, doesn't create other methods response other requests, such request example:

/odata/hotels(1)/room

owing there's no methods responding ~/entityset/key/navigation, web api odata can't find method in controller, throws above error message.

my try:

you can modify meet requirement. hope can you.

thanks.

sam


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -