You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
In a webapi project, I would like to customize ODataSerializerProvider by deriving it in ODataCustomODataSerializerProvider class to serialize a custom type, ie Dictionary<int, List>, in OData, but the ODataCustomODataSerializerProvider is never instanciated.
Reproduce steps
publicclassODataCustomODataSerializerProvider:ODataSerializerProvider{publicODataCustomODataSerializerProvider(IServiceProviderserviceProvider):base(serviceProvider){}publicoverrideIODataEdmTypeSerializerGetEdmTypeSerializer(IEdmTypeReferenceedmType){if(edmType.FullName()==typeof(Dictionary<int,List<int>>).FullName){// return Do something}returnbase.GetEdmTypeSerializer(edmType);}}
To initialize it in OData, the following instructions are used in Startup:
Expected behavior
The method GetEdmTypeSerializer of the ODataCustomODataSerializerProvider must be called when OData needs to serialize data from the method GetTest() of derived ODataController.
What is wrong? Or what is missing?
The text was updated successfully, but these errors were encountered:
Be noted, OData works fine using the POCO class, however, the Dictionary is not a POCO class, is there any reason that you have to use the Dictionary<int, List<int>> to define the property.
Be noted for OData team, OData core vocabulary introduces the 'Core.Dictionary' as Open complex type. Consider to use this Edm complex type to build the C# dictionary meanwhile use the OpenPropertyConstraint to limit the key/value type of the Dictionary.
Assemblies affected
ASP.NET Core OData 8.2.4
Describe the bug
In a webapi project, I would like to customize ODataSerializerProvider by deriving it in ODataCustomODataSerializerProvider class to serialize a custom type, ie Dictionary<int, List>, in OData, but the ODataCustomODataSerializerProvider is never instanciated.
Reproduce steps
To initialize it in OData, the following instructions are used in Startup:
Then in a OData derived controller, I call its method GetTest():
With TestInfoDto, complexe type:
Rregistered in OData by:
Expected behavior
The method GetEdmTypeSerializer of the ODataCustomODataSerializerProvider must be called when OData needs to serialize data from the method GetTest() of derived ODataController.
What is wrong? Or what is missing?
The text was updated successfully, but these errors were encountered: