title: Is there a more efficient way to query data and pass as a View Model List to a View?
body: <p>I have an <strong>Item</strong> model mapping to the DB like so: </p>
  
  <pre><code>public class Item
  {
      public int ItemId { get; set; }
      public DateTime Created { get; set; }
      public string Title { get; set; }
  }
  </code></pre>
  
  <p>To display lists of these items, I have created a <strong>ItemSummaryViewModel</strong> like so: </p>
  
  <pre><code>public class ItemSummaryViewModel 
  {
      public int ItemId { get; set; }
      public string Title { get; set; }   
  
      public ItemSummaryViewModel(Item item)
      {
          this.ItemId = item.ItemId;
          this.Title = item.JobTitle + " " + item.Created.ToString("ddd d MMM HH:mm");
      }
  }
  </code></pre>
  
  <p>I have also created a class to take a  <strong>List&lt; Item ></strong>  and return a <strong>List&lt; ItemSummaryViewModels ></strong> like so:</p>
  
  <pre><code>public class ItemSummaryViewModelList : List&lt;ItemSummaryViewModel&gt;
  {
      public ItemSummaryViewModelList(List&lt;Item&gt; items)
      {
          foreach (Item i in items)
          {
              ItemSummaryViewModel itemSummary = new ItemSummaryViewModel(i);
              this.Add(itemSummary);
          }
      }
  }
  </code></pre>
  
  <p>Finally, we use the controller to pass the list into the View like so: </p>
  
  <pre><code>    public ActionResult Index()
      {
          //IEnumerable&lt;ItemSummaryViewModel&gt; itemsummaries = new IEnumerable&lt;ItemSummaryViewModel&gt;();
  
          List&lt;Item&gt; ListOfItems = db.Items.ToList();
  
          ItemSummaryViewModelList ListOfItemViewModels = new ItemSummaryViewModelList(ListOfItems);
  
          return View(ListOfItemViewModels);
      }
  </code></pre>
  
  <p>My Questions Are: </p>
  
  <ol>
  <li><p>Is there a more efficient or "best practice" way of doing this? </p></li>
  <li><p>To transform the list of DB models (<strong>Item</strong>) into a list of displayable View Models (<strong>ItemSummaryViewModels</strong>), we currently iterate through each item in the list and transform them individually.  Is there a more efficient way of doing this ? </p></li>
  </ol>
  
  <p>Essentially we're querying the DB and assigning the data to a ViewModel for display as a list.  I can't help feeling that I'm "going round the houses" a bit and that there might be a more efficient or "best practice way of doing this. </p>
  
  <p>Is there a better way?</p>
  
  <p>Thanks</p>