title: Passing IEnumerable<Object> to ViewModel - Does Object need to be ViewModel?
body: <p>Getting my head around MVC today and ran across the best practice of not passing a Model directly to a view.  Instead, use a ViewModel.</p>
  
  <p>I researched AutoMapper and plan on using it to map my ViewModels to the respective Models.  And I understand that AutoMapper is smart enough to map IEnumerable to IEnumerable without a separate mapping, as long as source and dest are mapped.</p>
  
  <p>But I'm a bit confused about how to handle passing an IEnumerable in my ViewModel to my view.  I currently have my page working using a ViewModel that includes IEnumerable but I read that this is just as bad as passing the IEnumerable directly to the view.  So do I need a separate ViewModel to hold the object which will be used in an IEnumerable property of the main ViewModel?</p>
  
  <p>So where Activity is the Model in question:</p>
  
  <pre class="lang-cs prettyprint-override"><code>public class ActivityHistoryViewModel
  {
      public IEnumerable&lt;Activity&gt; activities { get; set; }
  }
  </code></pre>
  
  <p>do I need to create ActivityViewModel and write my ActivityHistoryViewModel like this?</p>
  
  <pre class="lang-cs prettyprint-override"><code>public class ActivityHistoryViewModel
  {
      public IEnumerable&lt;ActivityViewModel&gt; activities { get; set; }
  }
  </code></pre>
  
  <p>Is there an easier way to do this?</p>