简体   繁体   中英

How to make dynamic edm model support odata queries

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 WebApi现在不支持未键入方案中的查询选项,并且关于此功能存在未解决的问题

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM