asp.net-web-api – MaxExpansionDepth,带有最新的webapi和微风

我最近更新了我的所有nuget软件包到最新的EF6,breeze 1.4.5,system.web.http.odata 5.0.0.0,以及所有其他可用的好位.

现在,有一个查询包含像x.y.z这样的扩展,我得到如下错误:

A first chance exception of type 'Microsoft.Data.OData.ODataException' occurred in System.Web.Http.OData.dll

Additional information: The request includes a $expand path which is too deep. The maximum depth allowed is 2. To increase the limit,set the 'MaxExpansionDepth' property on QueryableAttribute or ODataValidationSettings.

我查看了建议的修复程序.如果我在查询的breeze’端点’上添加一个Queryable属性,它似乎会导致各种其他问题.我的猜测是它会干扰微风的预期行为,并以不同的方式格式化结果.

然后,我通过GlobalConfiguration.Configuration …查看了使用HttpConfiguration EnableQuerySupport扩展方法,但似乎没有效果(参见Supporting OData Query Options)

有没有人知道如何更改默认的webapi行为?

谢谢.

解决方法

你需要在你的breeze控制器IQueryable方法中添加一个BreezeQueryable属性,就像这样……

[BreezeQueryable(MaxExpansionDepth = 3)]
    public IQueryable<Customer> Customers()
    {
        ...
    }

dawei

【声明】:唐山站长网内容转载自互联网,其相关言论仅代表作者个人观点绝非权威,不代表本站立场。如您发现内容存在版权问题,请提交相关链接至邮箱:bqsm@foxmail.com,我们将及时予以处理。