我试图请求此查询:
http://services.odata.org/V4/TripPinService/People('russellwhyte')/AddressInfo/Microsoft.OData.SampleService.Models.TripPin.AirportLocation
所以,我试图从AirportLocation
获取所有People('russellwhyte')
。但是,我收到此错误消息:
"error": {
"code": "InternalServerError",
"message": "Type cast segment 'Microsoft.OData.SampleService.Models.TripPin.AirportLocation' after a collection which is not of entity type is not allowed.",
"innererror": {...
}
这是与Location
复杂类型相关的架构:
<ComplexType Name="Location" OpenType="true">
<Property Name="Address" Type="Edm.String" Nullable="false" />
<Property Name="City" Type="Microsoft.OData.SampleService.Models.TripPin.City" Nullable="false" />
</ComplexType>
<ComplexType Name="EventLocation" BaseType="Microsoft.OData.SampleService.Models.TripPin.Location" OpenType="true">
<Property Name="BuildingInfo" Type="Edm.String" />
</ComplexType>
<ComplexType Name="AirportLocation" BaseType="Microsoft.OData.SampleService.Models.TripPin.Location" OpenType="true">
<Property Name="Loc" Type="Edm.GeographyPoint" Nullable="false" SRID="4326" />
</ComplexType>
因此,Location
复杂类型是AirportLocation
和EventLocation
的基本类型。
任何想法?
答案 0 :(得分:0)
也许旅行服务没有实现这样的功能。但是,它确实支持OData。
基本上,在常规路由中,您应该在控制器中添加相应的方法。例如,如果您具有以下继承:
Address
CnAddress : Address
UsAddress : Address
实体类型Customer
具有名为Locations
的属性,其类型为IList<Address>
您应该在GetLocationsOfCnAddress
GetLocationsOfUsAddress
或CustomersController : ODataController
的方法