Note: This work around is for https://github.com/OData/WebApi/issues/170, which is not applicable for Microsoft.AspNetCore.OData v7.x.
When SingleResult.Create takes in a query that returns an empty result, a SerializationException is being thrown.
Let’s see a work-around about this issue.
First of all, we define the NullEntityTypeSerializer to handle null value:
Now, we can define a NullSerializerProvider, we need to avoid the situation of function,action call:
Add NullSerializerProvider in ODataMediaTypeFormatters: