title: Enabling nested any queries on OData V4 endpoints with WebAPI
body: <p>I'm trying to build a nested any query like this ...</p>
  
  <blockquote>
    <p>~/Api/Calendar?$filter=Roles/any(r:r/User/any(u:u/Name eq 'Joe
    Bloggs'))</p>
  </blockquote>
  
  <p>if I remove the inner any clause leaving me with ...</p>
  
  <blockquote>
    <p>~/Api/Calendar?$filter=Roles/any(r:r/User/any())</p>
  </blockquote>
  
  <p>... then the endpoint returns ...</p>
  
  <pre><code>{
      "error": {
          "code": "",
          "message": "The query specified in the URI is not valid. The Any/All nesting limit of '1' has been exceeded. 'MaxAnyAllExpressionDepth' can be configured on ODataQuerySettings or EnableQueryAttribute."
      }
  }
  </code></pre>
  
  <p>... which I think lends some light on the problem but I actually have here.</p>
  
  <p>So far I have tried to raise this limit with this during my context initialisation but it doesn't appear to be working ....</p>
  
  <pre><code>config.AddODataQueryFilter(new EnableQueryAttribute { MaxAnyAllExpressionDepth = 3 });
  </code></pre>
  
  <p>does anyone have any ideas how I can do this globally (i don't want to have to go to every get action on every controller and set the depth.</p>
  
  <p>UPDATE:</p>
  
  <p>So it turns out where I inherit from my own baseEntityController, on the actions I had the EnableQuery attribute which superceeded my global config change hense the reason my changes were not respected.</p>
  
  <p>Simply removing the attribute from the actions themselves has all controllers that inherit from my base working with this new nested any and all limit, but i seem to now have the side effect that expands don't work any more ...</p>
  
  <pre><code>var query = new EnableQueryAttribute {
      MaxExpansionDepth = 8,
      PageSize = 100,
      MaxAnyAllExpressionDepth = 3,
      AllowedFunctions = System.Web.OData.Query.AllowedFunctions.All,
      AllowedLogicalOperators = System.Web.OData.Query.AllowedLogicalOperators.All,
      AllowedQueryOptions = System.Web.OData.Query.AllowedQueryOptions.All,
      AllowedArithmeticOperators = System.Web.OData.Query.AllowedArithmeticOperators.All,
      MaxTop = 1000
  };
  config.AddODataQueryFilter(query);
  </code></pre>
  
  <p>.. as you can see I tried throwing lots of extras in there but it's not having any of it!</p>