title: MVC Razor view nested foreach's model
body: <p>Imagine a common scenario, this is a simpler version of what I'm coming across.  I actually have a couple of layers of further nesting on mine....</p>
  
  <p>But this is the scenario</p>
  
  <p>Theme contains List
  Category contains List
  Product contains List</p>
  
  <p>My Controller provides a fully populated Theme, with all the Categories for that theme, the Products within this categories and the their orders.</p>
  
  <p>The orders collection has a property called Quantity (amongst many others) that needs to be editable.</p>
  
  <pre><code>@model ViewModels.MyViewModels.Theme
  
  @Html.LabelFor(Model.Theme.name)
  @foreach (var category in Model.Theme)
  {
     @Html.LabelFor(category.name)
     @foreach(var product in theme.Products)
     {
        @Html.LabelFor(product.name)
        @foreach(var order in product.Orders)
        {
            @Html.TextBoxFor(order.Quantity)
            @Html.TextAreaFor(order.Note)
            @Html.EditorFor(order.DateRequestedDeliveryFor)
        }
     }
  }
  </code></pre>
  
  <p>If I use lambda instead then then I only seem to get a reference to the top Model object, "Theme" not those within the foreach loop.</p>
  
  <p>Is what I'm trying to do there even possible or have I overestimated or misunderstood what is possible?</p>
  
  <p>With the above I get an error on the TextboxFor, EditorFor, etc</p>
  
  <blockquote>
    <p>CS0411: The type arguments for method
    'System.Web.Mvc.Html.InputExtensions.TextBoxFor(System.Web.Mvc.HtmlHelper,
    System.Linq.Expressions.Expression>)'
    cannot be inferred from the usage. Try specifying the type arguments
    explicitly.</p>
  </blockquote>
  
  <p>Thanks.</p>