How to make edm support dynamically with single queries

I am trying to adapt a DynamicEdmModelCreation sample from https://github.com/OData/ODataSamples/tree/master/WebApi/v4/DynamicEdmModelCreation into a working version of v3 (I want to load odata directly into excel, which does not yet support odata v4)

I added config.AddODataQueryFilter() to the setting and [EnableQuery] in the controller's getler method, but now I get an exception:

In System.Web.Http.OData.dll

The first random error like "System.Runtime.Serialization.SerializationException" occurred

Additional Information: "EnumerableQuery`1" cannot be serialized using ODataMediaTypeFormatter.

which is 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 Getler method returns an EdmEntityObjectCollection problem? I would think that just adding the EnableQuery attribute would be enough for the structure to know how to apply this query operation to the EdmEntityObjectCollection returned to me (which will have much more data than may be necessary)

+5
source share
1 answer

What you did right, but OData WebApi now does not support query parameters in a non-printable script, and there is an open issue about this function.

+4
source

Source: https://habr.com/ru/post/1216312/


All Articles