Search code examples
odataupgradecompatibility

OData 6.0 missing ODataEntityTypeSerializer


I am trying to upgrade OData package (Microsoft.AspNet.OData) from v5.9 to v6.0 and my code break because I have a class that extends ODataEntityTypeSerializer.

I search for that in object browser and it was removed. When I back to v5.9.1 it works.

Is there a replacement for ODataEntityTypeSerializer in new 6.0 version or this is just a compatibility break?

My derived class is a way to prevent null value serialization. I write the new provider to treat null based on this response on SO.

 public class NullEntityTypeSerializer : ODataEntityTypeSerializer
    {
        public NullEntityTypeSerializer(ODataSerializerProvider serializerProvider)
            : base(serializerProvider)
        { }

        public override void WriteObjectInline(object graph, IEdmTypeReference expectedType, ODataWriter writer, ODataSerializerContext writeContext)
        {
            if (graph != null)
            {
                base.WriteObjectInline(graph, expectedType, writer, writeContext);
            }
        }
    }

UPDATE (jul/18): The problem with SingleResult.Create() that generate this work around was fixed in v7.0 and this is not necessary anymore. Check https://github.com/OData/WebApi/issues/170


Solution

  • According to https://odata.github.io/WebApi/#07-18-6-0 You should use ODataResourceSerializer.