1

I have three entities, in an inheritance hierarchy as shown below.

<EntityType Name="Base" Abstract="true">
    <Property Name="id" Type="Edm.String" Nullable="false" />
</EntityType>

<EntityType Name="Derived1" Abstract="true" BaseType="Base">
    <NavigationProperty Name="idps" Type="Collection(Idps)" />
</EntityType>

<EntityType Name="Derived2" Abstract="true" BaseType="Base">
    <NavigationProperty Name="attributes" Type="Collection(Attributes)" />
</EntityType>

I want to support $select and $expand query options for idps and attributes.

/base?$select=idps gives me below error

The query specified in the URI is not valid. Could not find a property named 'idps' on type 'Base'."

What would be the right odata option and how can I support that?

Abhishek Agrawal
  • 2,183
  • 1
  • 17
  • 24

2 Answers2

1

ODL supports type cast segment in the $select and $expand.

Here's some test cases that you can refer to:

1) https://github.com/OData/WebApi/blob/master/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/NavigationPropertyOnComplexType/SelectImprovementOnComplexTypeTests.cs#L141

2) https://github.com/OData/WebApi/blob/master/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/NavigationPropertyOnComplexType/SelectImprovementOnComplexTypeTests.cs#L284

The test cases cover the complex type type cast, so does it for entity type cast.

Sam Xu
  • 3,264
  • 1
  • 12
  • 17
0

I was able to resolve this issue with a query similar to the following:

/base?$select=Derived1/idps

In my case, my OData entity types have an explicit namespace on them, so I had to actually use a query similar to the following:

/base?$select=Namespace.Derived1/idps

Rami A.
  • 10,302
  • 4
  • 44
  • 87