title: .NET Core API return list and list count
body: <p>I am trying to return a complex object as a JSON with the .NET Core 2.1 API, using the OK function.</p>
  
  <p>The complex object consists of an array of anonymous objects and the count of the entire unfiltered dataset. </p>
  
  <p>I am using a JavaScript library that is expecting the JSON in this format:</p>
  
  <pre><code>{ 
    data: dataFiltered,
    count: dataUnfiltered.length
  }
  </code></pre>
  
  <p>The C# filtered anonymous object looks like this:</p>
  
  <pre><code>var unfiltedDataCount = product.Where(p =&gt; p.CategoryId == categoryId).Count();
  var autoCompleteData = products.Select(p =&gt; new { name = p.Name, productId = p.ProductId, categoryId = p.CategoryId}).ToList();
  </code></pre>
  
  <p>This works: native behavior </p>
  
  <pre><code>return Ok(autoCompleteData);
  </code></pre>
  
  <p>This does not work: Visual Studio report errors (the name "data" and "count" does not exist in the current context.)</p>
  
  <pre><code>return ok( new { data: autoCompleteData, count: unfiltedDataCount});
  </code></pre>