MaxExpansionDepth with latest webapi and breeze

不打扰是莪最后的温柔 提交于 2019-12-19 16:23:12

问题


I have recently updated all of my nuget packages to the latest for EF6, breeze 1.4.5, system.web.http.odata 5.0.0.0, and all the other good bits available.

Now, with one query that contains an expansion like x.y.z I get an error as follows:

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.

I looked into the suggested fixes. If I add a Queryable attribute on the breeze 'endpoint' being queried, it appears to cause all sorts of other problems. My guess is it interferes with breeze's expected behaviour and formats the results differently.

I then looked into the using the HttpConfiguration EnableQuerySupport extension method, through GlobalConfiguration.Configuration..., but that appears to have no effect (see Supporting OData Query Options)

Does anybody have any idea how I can change the default webapi behaviour?

Thanks.


回答1:


you need to add a BreezeQueryable attribute to your breeze controller IQueryable method like this ...

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


来源:https://stackoverflow.com/questions/19668693/maxexpansiondepth-with-latest-webapi-and-breeze

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!