title: How to use Breeze IQueryable with CORS?
body: <p>I use a method to add CORS handlers to my response that is called by a client using Breeze.</p>
  
  <p>You can read more about how I got that working here: <a href="https://stackoverflow.com/questions/17045327/controller-not-filtering-data-in-breeze-query-in-dotnetnuke-module">Controller not filtering data in Breeze query in DotNetNuke Module</a></p>
  
  <p>However, I noticed that while $filter works, <strong>$expand and $select</strong> do not. </p>
  
  <p><strong>So my question is: How can I use return a HttpResponseMessage Type and still use Breeze (I need to do this for CORS).</strong></p>
  
  <p>To prove this, I downloaded and changed the Todos sample:</p>
  
  <p><strong>Original method (works)</strong>  </p>
  
  <pre><code>http://example/api/todos/todos?$select=isdone
  </code></pre>
  
  <pre class="lang-c# prettyprint-override"><code>[HttpGet]
  public IQueryable&lt;TodoItem&gt; Todos()
  {
      return _contextProvider.Context.Todos;
  }
  </code></pre>
  
  <p><strong>My method with CORS wrapper (does not expand or select)</strong></p>
  
  <pre><code>http://example/api/todos/TodosCors?$select=isdone
  </code></pre>
  
  <pre class="lang-c# prettyprint-override"><code>[HttpGet]
  [Queryable(AllowedQueryOptions = AllowedQueryOptions.All)]
  public HttpResponseMessage TodosCors()
  {
      var response = Request.CreateResponse(HttpStatusCode.OK, (IQueryable&lt;TodoItem&gt;)_contextProvider.Context.Todos);
      return ControllerUtilities.GetResponseWithCorsHeader(response);
  }
  
      public static HttpResponseMessage GetResponseWithCorsHeader(HttpResponseMessage response)
      {
          response.Headers.Add("Access-Control-Allow-Origin", "*");
          return response;
      }
  </code></pre>