title: Does MVC not json-serialize other properties on a model that implements IEnumerable<T>?
body: <p>I don't know why I'm just now noticing this behavior for the first time. Looking to confirm whether this is designed behavior, or whether I'm missing something.</p>
  
  <p>Say I have a viewmodel that implements <code>IEnumerable&lt;T&gt;</code>, and provides additional properties. For example:</p>
  
  <pre><code>public class MyResultsViewModel : IEnumerable&lt;MyResultViewModel&gt;
  {
      public IEnumerable&lt;MyResultViewModel&gt; Results { get; set; }
      public string SomeAdditionalProperty { get; set; }
  
      public IEnumerator&lt;MyResultViewModel&gt; GetEnumerator()
      {
          return Results.GetEnumerator();
      }
      IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator; }
  }
  </code></pre>
  
  <p>Say I also have a controller which returns this model as json. For example:</p>
  
  <pre><code>public ActionResult MyResults()
  {
      var entities = PrivateMethodToGetEntities();
      var models = Mapper.Map&lt;MyResultsViewModel&gt;(entities);
      models.SomeAdditionalProperty = "I want this in the JSON too";
      return Json(models, JsonRequestBehavior.AllowGet);
      // models now contains a populated Results as well as the add'l string prop
  }
  </code></pre>
  
  <p>When I get the results back from a JSON request on the client, it always comes back as an array. For example:</p>
  
  <pre><code>$.get('/Path/To/MyResults')
  .success(function (results) {
      alert(results.SomeAdditionalProperty); // this alerts 'undefined'
      alert(results.length); // this alerts the size / count of Results
      alert(results[0]); // this alerts object
      // inspecting results here shows that it is a pure array, with no add'l props
  });
  </code></pre>
  
  <p>Before I refactor to make the viewmodel not implement <code>IEnumerable&lt;T&gt;</code>, I want to get some confirmation that this is by design and should be expected. I guess it makes sense, since the javascript array object's prototype would have to be extended to accommodate the additional properties.</p>
  
  <p><strong>Update:</strong></p>
  
  <p>I've made the following changes to the viewmodel, to avoid naming the internal enumerable <code>Results</code>:</p>
  
  <pre><code>public class MyResultsViewModel : IEnumerable&lt;MyResultViewModel&gt;
  {
      public IEnumerable&lt;MyResultViewModel&gt; NotNamedResults { get; set; }
      public string SomeAdditionalProperty { get; set; }
  
      public IEnumerator&lt;MyResultViewModel&gt; GetEnumerator()
      {
          return NotNamedResults.GetEnumerator();
      }
      IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator; }
  }
  </code></pre>
  
  <p>With this change, the behavior remains. <code>alert(JSON.stringify(results))</code> yields normal array syntax for my enumerated collection of <code>MyResultViewModel</code>s:</p>
  
  <blockquote>
    <p>[{"ResultProp1":"A","ResultProp2":"AA","ResultProp3":"AAA"},{"ResultProp1":"B","ResultProp2":"BB","ResultProp3":"BBB"},{"ResultProp1":"C","ResultProp2":"CC","ResultProp3":"CCC"},{"ResultProp1":"D","ResultProp2":"DD","ResultProp3":"DDD"},{"ResultProp1":"E","ResultProp2":"EE","ResultProp3":"EEE"}]</p>
  </blockquote>
  
  <p>Is still seems that the additional property is being lost between when the controller action returns the <code>JsonResult</code> and the jquery <code>success</code> function is invoked.</p>