8

我最近将我所有的 nuget 包更新为最新的 EF6、breeze 1.4.5、system.web.http.odata 5.0.0.0 以及所有其他可用的好位。

现在,对于一个包含像 xyz 这样的扩展的查询,我收到如下错误:

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.

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

然后,我通过 GlobalConfiguration.Configuration... 研究了使用 HttpConfiguration EnableQuerySupport 扩展方法...,但这似乎没有效果(请参阅Supporting OData Query Options

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

谢谢。

4

1 回答 1

20

你需要像这样向你的微风控制器 IQueryable 方法添加一个 BreezeQueryable 属性......

    [BreezeQueryable(MaxExpansionDepth = 3)]
    public IQueryable<Customer> Customers()
    {
        ...
    }
于 2013-10-30T17:01:26.737 回答