[英]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) 我一直在尝试将DynamicEdmModelCreation示例从https://github.com/OData/ODataSamples/tree/master/WebApi/v4/DynamicEdmModelCreation调整为可行的v3版本(我想将odata直接加载到excel中,而不是支持odata v4)
I added config.AddODataQueryFilter()
to the setup and [EnableQuery]
on the Controller's get method, but I now receive the exception: 我将
config.AddODataQueryFilter()
添加到Controller的get方法的setup和[EnableQuery]
,但我现在收到异常:
A first chance exception of type 'System.Runtime.Serialization.SerializationException' occurred in System.Web.Http.OData.dll
System.Web.Http.OData.dll中发生'System.Runtime.Serialization.SerializationException'类型的第一次机会异常
Additional information: 'EnumerableQuery`1' cannot be serialized using the ODataMediaTypeFormatter.
附加信息:'EnumerableQuery`1'无法使用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 这是从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? 事实上我的Controller的Get方法返回
EdmEntityObjectCollection
是一个问题吗? 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) 我原本以为只需添加EnableQuery属性就足以让框架知道如何将该查询操作应用于我正在返回的
EdmEntityObjectCollection
(这将包含比可能需要的更多的数据)
您所做的是对的,但OData WebApi现在不支持未键入方案中的查询选项,并且关于此功能存在未解决的问题 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.