【发布时间】:2020-05-14 17:54:13
【问题描述】:
我想为给定的 OData api (v4) 一次性获取尽可能多的嵌套数据。但是,我似乎无法扩展所有派生类型的导航属性以及不同导航属性中的所有其他对象。
例如,有 TripPin OData v4 示例服务: https://services.odata.org/V4/(S(xjqbds2oavibr01gt1fny24s))/TripPinServiceRW/
我想尽可能多地获取关于人的信息: https://services.odata.org/V4/(S(xjqbds2oavibr01gt1fny24s))/TripPinServiceRW/People?$expand=Trips($expand=PlanItems) 这将向我展示 api 中可用的 People Trips 的 PlanItems:
...,
PlanItems: [
...,
{
@odata.type: "#Microsoft.OData.SampleService.Models.TripPin.Flight",
PlanItemId: 13,
ConfirmationCode: "JH38143",
StartsAt: "2014-01-04T17:55:00Z",
EndsAt: "2014-01-04T20:45:00Z",
Duration: "PT0S",
SeatNumber: null,
FlightNumber: "AA4035"
},
{
@odata.type: "#Microsoft.OData.SampleService.Models.TripPin.Event",
PlanItemId: 12,
ConfirmationCode: "4372899DD",
StartsAt: "2014-01-02T13:00:00Z",
EndsAt: "2014-01-02T16:00:00Z",
Duration: "PT3H",
Description: "Client Meeting",
OccursAt: {
Address: "100 Church Street, 8th Floor, Manhattan, 10007",
City: {
CountryRegion: "United States",
Name: "New York City",
Region: "New York"
},
BuildingInfo: "Regus Business Center"
}
},
...
PlanItems 包含不同派生类型的对象,即 Flight 和 Event。航班有 3 个其他导航属性,如元数据 (https://services.odata.org/V4/(S(xjqbds2oavibr01gt1fny24s))/TripPinServiceRW/$metadata) 中所述:From、To 和 Airline。我想将它们与所有其他信息一起获取。但如果可能的话,我不知道怎么做。
【问题讨论】:
标签: odata