MaxExpansionDepth带有最新的webapi和微风

时间:2013-10-29 20:43:23

标签: asp.net-web-api odata breeze

我最近将所有我的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行为吗?

感谢。

1 个答案:

答案 0 :(得分:20)

你需要在你的breeze控制器IQueryable方法中添加一个BreezeQueryable属性,如下所示......

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