OData / ODataConnectedService

A Visual Studio extension for generating client code for OData Services
Other
81 stars 44 forks source link

Type Edm.PropertyPath is not supported #343

Open HeikoTheissen opened 1 year ago

HeikoTheissen commented 1 year ago

Describe the bug

A complex type with a property of type Edm.PropertyPath leads to an error. But this type (and others, like Edm.NavigationPropertyPath) can occur in OData V4 services as type of an annotation term.

Version of the Project affected

ODataConnectedService 2022+ v1.0.1 Microsoft Visual Studio Professional 2022 (64-bit) v17.5.4 Microsoft.Odata.Client v7.15.0

To Reproduce

Import the following OData V4 metadata:

<edmx:Edmx Version="4.0" xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx">
<edmx:DataServices>
   <Schema Namespace="self" xmlns="http://docs.oasis-open.org/odata/ns/edm">
     <EntityContainer Name="EntityContainer">
       <EntitySet Name="Dates" EntityType="self.Date" />
     </EntityContainer>
     <EntityType Name="Date">
       <Key>
         <PropertyRef Name="id" />
       </Key>
       <Property Name="id" Type="Edm.Guid" Nullable="false" />
     </EntityType>
     <Term Name="MainProperty" Type="self.MainPropertyType" AppliesTo="EntityType" />
     <ComplexType Name="MainPropertyType">
       <Property Name="Main" Type="Edm.PropertyPath" />
     </ComplexType>
   </Schema>
</edmx:DataServices>
</edmx:Edmx>

Expected behavior

Generation of a working C# OData client.

Actual behavior

An error occurs:

Adding OData Connected Service to the project failed: Could not get CLR type name for EDM type 'Edm.PropertyPath'

Screenshots

n/a

Additional context

n/a

habbes commented 1 year ago

Marking this as a feature request because the library doesn't currently have any suitable representation for Edm.PropertyPath as type property. It's not clear what code should be generated for this. We'll have to do some design work on this. Maybe we should create a custom type to represent Edm.PropertyPath in CLR objects.