title: Cannot implicitly convert type 'System.Collections.Generic.List to 'Models.CustomerViewModel'
body: <p>I am trying to pass a list of data containing two objects that are contained in a custom interface, </p>
  
  <p>My interface consists of </p>
  
  <pre><code>public interface ICustomersAndSitesRepository
  {
      IQueryable&lt;CustomerSite&gt; CustomerSites { get; }
      IQueryable&lt;Customer&gt; Customers { get; }
      IQueryable&lt;ICustomersAndSitesRepository&gt; CustomerAndSites { get; }
  }
  </code></pre>
  
  <p>Then my repository i have this method</p>
  
  <pre><code>public IQueryable &lt;ICustomersAndSitesRepository&gt; CustomerAndSites
      {
          get { return CustomerAndSites; }
      }
  </code></pre>
  
  <p>Then i have my viewmodel</p>
  
  <pre><code>public class CustomerSitesListViewModel
  {
      public IList&lt;CustomerSite&gt; CustomerSites { get; set; }
      public PagingInfo PagingInfo { get; set; }
      public CustomerViewModel Customers { get; set; }
  
  }
  </code></pre>
  
  <p>And my controller action</p>
  
  <pre><code>public ViewResult List([DefaultValue(1)] int page)
  {
  
      var customersWithSitesToShow = customersAndSitesRepository.CustomerAndSites;
      var viewModel = new CustomerSitesListViewModel
      {                
          Customers = customersWithSitesToShow.Skip((page - 1) * PageSize).Take(PageSize).ToList(),
          PagingInfo = new PagingInfo
          {
              CurrentPage = page,
              ItemsPerPage = PageSize,
              TotalItems = customersWithSitesToShow.Count()
          }
      };
  
      return View(viewModel);  //Passed to view as ViewData.Model (or simply model)
  }
  </code></pre>
  
  <p>This line throws an error as im trying to pass the collection to my paging function thats expecting a list.</p>
  
  <pre><code>    Customers = customersWithSitesToShow.Skip((page - 1) * PageSize).Take(PageSize).ToList(),
  </code></pre>
  
  <p>The error is</p>
  
  <pre><code> Cannot implicitly convert type 'System.Collections.Generic.List to 'Models.CustomerViewModel'
  </code></pre>
  
  <p>Is there a way to convert the list that is being returned so that it can be used in the viewmodel?</p>
  
  <p>This is the customer view model</p>
  
  <pre><code>public class CustomerViewModel
  {
      public int Id { get; set; }
      public string CustomerName { get; set; }
      public string PrimaryContactName { get; set; }
      public string PrimaryContactNo { get; set; }
      public string PrimaryEmailAddress { get; set; }
      public string SecondaryContactName { get; set; }
      public string SecondaryContactNo { get; set; }
      public string SecondaryEmailAddress { get; set; }
      public DateTime RegisteredDate { get; set; }
      public string WasteCarrierRef { get; set; }
      public string UnitNo { get; set; }
      public string StreetName { get; set; }
      public string Town { get; set; }
      public string County { get; set; }
      public string Postcode { get; set; }
      public byte[] ImageData { get; set; }
      public string ImageMimeType { get; set; }
      public SiteViewModel Site { get; set; }
  }
  </code></pre>