I have been trying to adapt the DynamicEdmModelCreation sample from https://github.com/OData/ODataSamples/tree/master/WebApi/v4/DynamicEdmModelCreation into a workable v3 version (I want to load odata directly into excel, which doesn't support odata v4 yet)
I added config.AddODataQueryFilter()
to the setup and [EnableQuery]
on the Controller's get method, but I now receive the exception:
A first chance exception of type 'System.Runtime.Serialization.SerializationException' occurred in System.Web.Http.OData.dll
Additional information: 'EnumerableQuery`1' cannot be serialized using the ODataMediaTypeFormatter.
Which is being thrown from https://github.com/ASP-NET-MVC/aspnetwebstack/blob/master/OData/src/System.Web.Http.OData/OData/Formatter/ODataMediaTypeFormatter.cs#L577
Is the fact that my Controller's Get method is returning an EdmEntityObjectCollection
an issue? I would have thought that just adding the EnableQuery attribute would be enough for the framework to know how to apply that query operation to the EdmEntityObjectCollection
that I'm returning (which will have lots more data than potentially needed)
OData service uses an abstract data model called Entity Data Model (EDM) to describe the exposed data in the service. OData client can issue a GET request to the root URL of the OData service with $metadata to get an XML representation of the service's data model.
The odata. type annotation specifies the type of a JSON object or name/value pair. Its value is a URI that identifies the type of the property or object. For built-in primitive types the value is the unqualified name of the primitive type, specified as a URI fragment.
What you have done is right, but OData WebApi doesn't support query options in un-typed scenario now, and there is an open issue about this feature.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With