与最新的WebAPI和微风MaxExpansionDepth [英] MaxExpansionDepth with latest webapi and breeze

查看:374
本文介绍了与最新的WebAPI和微风MaxExpansionDepth的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近更新了所有我的NuGet包到最新的EF6,微风1.4.5,system.web.http.odata 5.0.0.0,并且所有可用的其他好位。

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.

现在,用包含像X.Y.Z扩展一个查询我得到一个错误如下:

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.

然后我调查了使用HttpConfiguration EnableQuerySupport扩展方法,通过GlobalConfiguration.Configuration ...,但似乎没有任何效果(见<一href=\"http://www.asp.net/web-api/overview/odata-support-in-aspnet-web-api/supporting-odata-query-options\">Supporting OData的查询选项)

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)

没有任何人有任何想法我怎么能更改默认的WebAPI行为?

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

感谢。

推荐答案

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

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

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

这篇关于与最新的WebAPI和微风MaxExpansionDepth的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆