问题
The excellent sample code: Support Composite Key in ASP.NET Web API OData illustrates how to create routing conventions to make WebApi OData work with composite keys.
However it is using ODataController (as one of the unanswered discussions on the sample code mentions) which I presume has many downsides (which I am yet to fully uncover)... has anyone created an example using the benefits of EntitySetController?
回答1:
Going forward the recommended approach is to directly derive from ODataController
. Visual Studio 2013 provides scaffolding for creating OData services based on ODataController. This has been found to be a much more flexible model than deriving from EntitySetController. You get complete control over what is done in your actions.
来源:https://stackoverflow.com/questions/22941889/webapi-entitysetcontroller-using-composite-keys