title: public definition of GetEnumerator in asp.net mvc missing?
body: <p>Should I manually create a definition for GetEnumerator? Seems like it should know...</p>
  
  <p>I get the following error: </p>
  
  <blockquote>
    <p>foreach statement cannot operate on
    variables of type
    'MvcAppNorthwind.Models.Product'
    because
    'MvcAppNorthwind.Models.Product' does
    not contain a public definition for
    'GetEnumerator'</p>
  </blockquote>
  
  <pre><code>Line 9:      &lt;h2&gt;&lt;%: ViewData["Message"] %&gt;&lt;/h2&gt;
  Line 10:     &lt;ul&gt;
  Line 11:     &lt;% foreach (MvcAppNorthwind.Models.Product p in ViewData.Model)  {   %&gt;
  Line 12:     &lt;li&gt;&lt;%= p.ProductName %&gt;&lt;/li&gt;
  Line 13:     &lt;% } %&gt;
  </code></pre>
  
  <p>In my controller I have this code:</p>
  
  <pre><code>  NorthwindDataContext db = new NorthwindDataContext(); 
  
      ViewData["Message"] = "Welcome to ASP.NET MVC!";
      var products = from p in db.Products
                     select p; 
  
  
      return View(products);
  </code></pre>
  
  <p>I changed the declaration in my view like this and now it works: </p>
  
  <pre><code>&lt;%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage&lt;IEnumerable&lt;MvcAppNorthwind.Models.Product&gt;&gt;" %&gt;
  </code></pre>
  
  <p><strong>But if you want to display or use data from several models in the same view? How do you do it then?</strong> </p>