2017-12-13 24 views
0

나는이 쿼리를 요청하기 위해 노력하고있어 :중 하나로, OData : 여행 쿼리 오류 캐스팅 복합 유형

http://services.odata.org/V4/TripPinService/People('russellwhyte')/AddressInfo/Microsoft.OData.SampleService.Models.TripPin.AirportLocation 

그래서, 내가 People('russellwhyte')의 모든 AirportLocation를 얻기 위해 노력하고있어. 그러나, 나는이 오류 메시지를 받고 있어요 :

<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 복합 형이 AirportLocationEventLocation의 기본 유형 :

"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 복합 형 관련 스키마입니다.

어떤 아이디어가 있습니까?

답변

0

아마도 여행 서비스에 이러한 기능이 구현되지 않았습니다. 그러나 OData에서 지원됩니다.

기본적으로 관례 라우팅에서는 컨트롤러에 해당 메서드를 추가해야합니다. 당신은 다음과 상속하는 경우 예를 들어, :

Address 
CnAddress : Address 
UsAddress : Address 

개체 유형 Customer 부동산 IList<Address>

당신이 방법은 CustomersController : ODataController

+0

GetLocationsOfCnAddress 또는 GetLocationsOfUsAddress 이름이 있어야 당신이 나를 어떤을 제공 할 수있는 유형 Locations을 임명했다 왜'GetLocationsOfCnAddress'와'GetLocationsOfUsAddress'를 가져야하는지 설명하는 문서를 제공하고 있습니까? 다른 한편, 어떤 서비스가 실제로 그러한 기능을 지원하는지 알고 있습니까? – Jordi

+0

대회 경로에 관한 문서는 http://odata.github.io/WebApi/#03-02-built-in-routing-conventions에서 찾을 수 있습니다. 그러나 그것은 재산 던지기를 언급하지 않는다. 아마 코드를 참조 할 수 있습니다. https://github.com/OData/WebApi/blob/master/src/System.Web.OData/OData/Routing/Conventions/PropertyRoutingConvention.cs#L65-L67 –