【问题标题】:OData 8 - What is the new Input Parameter syntax on an ODataController?OData 8 - ODataController 上的新输入参数语法是什么?
【发布时间】:2021-07-29 06:09:42
【问题描述】:

对于 oData 7,此代码允许我将 id 传递给我的 oDataController 函数。

    [HttpGet]
    [EnableQuery]
    [ODataRoute("Projects({id})")]
    public IActionResult GetProjects([FromODataUri] int id)
    {
        if (!ModelState.IsValid)
        {
            return BadRequest(ModelState);
        }
        ProjectEntity project = _Db.Projects.Where(i => i.Id == id).FirstOrDefault();
        return Ok(_AutoMapper.Map<ProjectDto>(project));
    }

更新到oData8后,找不到路由。什么是新语法?没有错误。

【问题讨论】:

    标签: c# asp.net-core asp.net-web-api odata blazor


    【解决方案1】:

    @汤姆克罗斯曼,

    从 ASP.NET Core OData 8.0 RC 开始,ODataRouteAttribute 就消失了。可以使用 ASP.NET Core 路由属性,例如 HttpGetAttribute 等。

    我有一个帖子可以参考:

    https://devblogs.microsoft.com/odata/attribute-routing-in-asp-net-core-odata-8-0-rc/

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-09-11
      • 1970-01-01
      • 2014-02-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-06-25
      相关资源
      最近更新 更多