I need to create a Serializer to support all of the following tasks:
- Removing null properties
- Removing Empty Lists
I noticed the Syntax of the ODataMediaTypeFormatter has been changed.
And I'm having trouble adding my Serialzation provider to the pipe.
Here what I've tried:
On WebApiConfig.cs:
var odataFormatters = ODataMediaTypeFormatters.Create();
odataFormatters.Add(new MyDataMediaTypeFormatter());
config.Formatters.InsertRange(0, odataFormatters);
Plus I've Created the following Odatameditatypeformatter:
public class MyODataMediaTypeFormatter : ODataMediaTypeFormatter
{
static IEnumerable<ODataPayloadKind> payloadKinds = new List<ODataPayloadKind>
{
ODataPayloadKind.Asynchronous,
ODataPayloadKind.Batch,
ODataPayloadKind.BinaryValue,
ODataPayloadKind.Collection,
ODataPayloadKind.EntityReferenceLink,
ODataPayloadKind.EntityReferenceLinks,
ODataPayloadKind.Error,
ODataPayloadKind.Delta,
ODataPayloadKind.IndividualProperty,
ODataPayloadKind.MetadataDocument,
ODataPayloadKind.Parameter,
ODataPayloadKind.Resource,
ODataPayloadKind.ServiceDocument,
ODataPayloadKind.Unsupported,
ODataPayloadKind.Value
};
public MyODataMediaTypeFormatter() : base(payloadKinds)
{
}
}
Currently I checked all the base methods and none of them seems to hit the breakpoint while creating a Get/Post request to my OData controllers.
Any one managed to do it on the new version of Microsoft.Aspnet.OData 7.0.1?