Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MaxExpansionDepth with latest webapi and breeze

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.

like image 884
Adam Avatar asked Oct 29 '13 20:10

Adam


1 Answers

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

    [BreezeQueryable(MaxExpansionDepth = 3)]
    public IQueryable<Customer> Customers()
    {
        ...
    }
like image 81
mabulu Avatar answered Oct 05 '22 01:10

mabulu