AspNetCoreOData icon indicating copy to clipboard operation
AspNetCoreOData copied to clipboard

Annotation to handle sanitization of field names in open types

Open marcus905 opened this issue 8 months ago • 3 comments

Assemblies affected ASP.NET Core OData 8.x

Describe the bug There is no way to handle special characters if present in dynamic properties in OData, causing:

"The property name '01.01' is invalid; property names must not contain any of the reserved characters ':', '.', '@'."

Reproduce steps in an IDictionary<string, object>, if the key contains a special character, on read it throws this error

Data Model

class Test {
        public string Id{ get; set; }


        //extradata
        public IDictionary<string, object> ExtraData { get; set; }
}

EDM (CSDL) Model

<edmx:Edmx xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx" Version="4.0">
<edmx:DataServices>
<Schema xmlns="http://docs.oasis-open.org/odata/ns/edm" Namespace="RY.Models">
<EntityType Name="Test" OpenType="true">
<Key>
<PropertyRef Name="Id"/>
</Key>
<Property Name="Id" Type="Edm.String" Nullable="false"/>
</EntityType>
</Schema>
</edmx:DataServices>
</edmx:Edmx>

Request/Response N/A

Expected behavior There needs to be, for the open type annotation, a way to specify that non-compliant field names must be sanitized before sending them out.

marcus905 avatar Jun 25 '24 15:06 marcus905