AspNetCoreOData icon indicating copy to clipboard operation
AspNetCoreOData copied to clipboard

Support strongly typed dictionaries for dynamic properties

Open mikepizzo opened this issue 2 years ago • 1 comments

Assemblies affected ASP.NET Core OData 8.x ModelBuilder

Describe the bug Today, we use the fact that a property of a CLR type is of type Dictionary<string,object> to determine that the type is an open type, and use the Dictionary<string,object> to store dynamic properties.

However, the service may impose an open property type constraint that specifies that dynamic properties are of a specific given type. In this case, the implementation of the dynamic property dictionary should be able to be of that type, for example, Dictionary<string,myAttributeType>. Ideally, modelbuilder would recognize this pattern and automatically apply the open property type constraint annotation to the type.

Work required: -Support strongly typed dictionaries in AspNetCore.OData. -Support strongly typed dictionaries in ModelBuilder

mikepizzo avatar Oct 17 '23 19:10 mikepizzo

Note that open property type constraint is a collection, so an ideal implementation of modelbuilder would look for any dictionaries and generate an open property type constraint for the value type in each such dictionary, and then the AspNetCore.OData serializer/deserializer would read/write the open properties to/from the appropriate dictionary.

mikepizzo avatar Oct 24 '23 17:10 mikepizzo