OData/WebApi

Cannot serialize EdmDeltaComplexObject in odata 7x and above

vasrinwork opened this issue · 0 comments

ODataResourceSerializer fails to serialize resource of type EdmDeltaComplexObject for Delta entities.

Assemblies affected

OData 7x and above

Reproduce steps

While trying to serialize the resource of type EdmDeltaComplexObject

public class Sample
{
    public string Description
    {  get; set;  }

    public SampleItemCollection Samplelist
    {  get; set;  }
}

public class SampleItemCollection : EdmDeltaComplexObject
{
     public IDictionary<string, object> DynamicProperties { get; set; }
}

When an instance of the above Sample class is edited and a delta sync request is sent to fetch the changes,
Expected response is:

{
  ""samplelist"": {
    ""key-samplelist"": {
      ""title"": ""Title"",
    }
  },
  ""description"": "an edit to sample item"
}

Actual response seen in v7x:

{
  ""samplelist"": {
  },
  ""description"": "an edit to sample item"
}

Additional detail

Reasoning:
In OData V5x & 6x Complex type property is treated as a struct property, and serialization for a complex property was performed similar to primitive property.
however, in OData v7x, complex properties are treated as a resource and classified as DynamicComplexProperties.

It looks like a feature gap/regression bug and solution would be to call the WriteDynamicComplexProperties for delta entities.