【问题标题】:OData get individual property: ~/entityset/key/navigation/propertyOData 获取单个属性:~/entityset/key/navigation/property
【发布时间】:2019-11-27 05:08:18
【问题描述】:

我需要从 OData(V4) 端点获取实体的个人属性。

这是一个简单的项目。模型、控制器和配置文件是here

$select 可以正常工作,但它与我们想要的有点不同。我们只需要获取一个属性(而不是具有一个属性的实体)以显示在某处的报告中。

现在我可以获得单独的导航和普通属性: http://localhost:64659/People(Guid)/Address, http://localhost:64659/People(Guid)/Name, http://localhost:64659/Address(Guid)/Name

但是,以下 URL 不起作用,因为我们试图获取导航属性的属性: http://localhost:64659/People(Guid)/Address/Name 错误是:

{
"error": {
    "code": "",
    "message": "No HTTP resource was found that matches the request URI 'http://localhost:64659/People(c6ef0e71-2107-4d58-bf0d-12d38f25045a)/Address/Name'.",
    "innererror": {
        "message": "No routing convention was found to select an action for the OData path with template '~/entityset/key/navigation/property'.",
        "type": "",
        "stacktrace": ""
    }
}

}

我找不到任何东西可以让它工作,感谢任何帮助。

【问题讨论】:

  • 如果问题不清楚请告诉我

标签: rest routing odata


【解决方案1】:

遇到同样的问题并使用 $select

http://localhost:64659/Address(Guid)?$select=Name

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-04-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-10-01
    • 2012-11-07
    • 1970-01-01
    相关资源
    最近更新 更多