私はこの基本ODataControllerを持っています
public abstract class BaseController<T> : ODataController where T : class
{
[EnableQuery]
public IHttpActionResult Get()
{
return Ok(Repository.AsQueryable());
}
[EnableQuery]
public IHttpActionResult Get(int key)
{
var entity = Repository.GetByKey(key);
return Ok(entity);
}
}
そして、この派生コントローラー
public class FoosController : BaseController<Foo>
{
}
ちゃんと打て.../odata/foos(1)
ます。しかし.../odata/foos
、このエラーを出してください:
{
"error": {
"code": "",
"message": "No HTTP resource was found that matches the request URI 'https://localhost:44300/odata/Foos'.",
"innererror": {
"message": "No action was found on the controller 'Foos' that matches the request.",
"type": "",
"stacktrace": ""
}
}
}
仮想にしてからGet()
、派生コントローラーでオーバーライドする必要があります。このような:
public class FoosController : BaseController<Foo>
{
[EnableQuery]
[ODataRoute("Foos")]
public override IHttpActionResult Get()
{
return base.Get();
}
}
Get()
ベースコントローラーで動作しないのはなぜGet(1)
ですか?