title: How to combine nested model lambdas in razor syntax
body: <p>My View Model</p>
  
  <pre><code>public class PostViewModel
  {
      public Post Post { get; set; }
  
      public IEnumerable&lt;Comment&gt; Comments { get; set; }
  }
  </code></pre>
  
  <p>In my razor view I am trying to get data for my comment</p>
  
  <pre><code>@using (Html.BeginForm("Comment", "Post"))
  {
  
  
      &lt;div class="form-group"&gt;
          @Html.LabelFor(m =&gt; m.Comments.Data);
          @Html.TextAreaFor(m =&gt; m.Comments.Data, new { @class = "form-control" })
      &lt;/div&gt;
  
      @Html.HiddenFor(m =&gt; m.Comments.Id)
      &lt;button type="submit" class="btn btn-primary"&gt; Comment &lt;/button&gt;
  }
  </code></pre>
  
  <p>But I am getting errors</p>
  
  <p>then I tried the following syntax</p>
  
  <pre><code>@using (Html.BeginForm("Comment", "Post"))
  {
  
      @foreach(var comment in Model.Comments)
      {
          &lt;div class="form-group"&gt;
              @Html.LabelFor(comment.Data);
              @Html.TextAreaFor(comment.Data, new { @class = "form-control" })
          &lt;/div&gt;
  
          @Html.HiddenFor(comment.Id)
          &lt;button type="submit" class="btn btn-primary"&gt; Comment &lt;/button&gt;
  
      }
  }
  </code></pre>
  
  <p>But I am still getting errors</p>
  
  <p>actually I am doing a blog project</p>
  
  <p>So, I am hoping to have Post, all old comment and new comment button in a Details page</p>