title: Display/list data from a different model (ViewModel)?
body: <p>I have a customer model</p>
  
  <pre><code>public class Customer
      {
          public int CustomerID { get; set; }
          public string CustomerName { get; set; }
          public string CustomerAddress1 { get; set; }
          public string CustomerAddress2 { get; set; }
          public string CustomerAddress3 { get; set; }
          public string CustomerAddress4 { get; set; }
          public string CustomerAddress5 { get; set; }
          public string CustomerAddress6 { get; set; }
          public string CustomerAddress7 { get; set; }
  }
  </code></pre>
  
  <p>I want to display all info from all customers in a profile view. I guess it is best to use a viewmodel because I also want to show other information in profile.</p>
  
  <p>I created a viewmodel</p>
  
  <pre><code> public class CustomerViewModel
      {
          public string CustomerAddress1 { get; set; }
          public string CustomerAddress2 { get; set; }
          public string CustomerAddress3 { get; set; }
      }
  </code></pre>
  
  <p>I do not really know how my profile controller should look like and have tested</p>
  
  <pre><code>        CustomerViewModel ViewModel = new CustomerViewModel();
  
          return View(ViewModel);
  </code></pre>
  
  <p>Viewmodel is null.</p>
  
  <p>Normally, if I want to get all customers but in the customer Controller I do like this.</p>
  
  <pre><code>var customer = db.Customers.ToList();
  return customer
  </code></pre>
  
  <p>And how should I list all the customers in the profile view?</p>
  
  <p>This is not working</p>
  
  <pre><code>@model xxx.ViewModels.CustomerViewModel
  
  @foreach (var item in Model)
  {
      item.Customer.CustomerAddress2
  }
  </code></pre>