title: MVC unsure how to retrieve related objects in a model
body: <p>I pass a viewmodel into view that looks like this</p>
  
  <pre><code>assessment
      questions   
          [0]
              QuestionText
              QuestionID
          [1]
              QuestionText
              QuestionID
  
      Answers
          [0]
              TheAnswer
              QuestionID
  </code></pre>
  
  <p>Basically my view has a list of questions and list of any answers that may have already chosen.</p>
  
  <p>I need to display all the questions and any chosen answer
  The link between question and answer is <code>QuestionID</code></p>
  
  <p>This is my razor code in the view which loops all the questions</p>
  
  <pre><code>@foreach (var question in Model.Assessment.Questions)
  {
      &lt;li class="row"&gt;
          &lt;div class="span9"&gt;
              @Html.Raw(question.QuestionText)
          &lt;/div&gt;
          &lt;div class="span3"&gt;
              @Html.Raw(&lt;--No idea what to put here--&gt;)
          &lt;/div&gt;
      &lt;/li&gt;
  }
  </code></pre>
  
  <p>How can I retrieve the selected answer for the question?</p>
  
  <p>EDIT</p>
  
  <p>Here are my models</p>
  
  <pre><code>public class Assessment
      {
          public int ID { get; set; }
          public Status Status { get; set; }
          public DateTime AssessmentDate { get; set; }
          public int AreaID { get; set; }
  
          public virtual Area Area { get; set; }
          public virtual ICollection&lt;Question&gt; Questions { get; set; }
          public virtual ICollection&lt;Answer&gt; Answers { get; set; }
      }
  
  public class Question
      {
          public int ID { get; set; }
          public string QuestionText { get; set; }
          public int DisplayNumber { get; set; }
          public int DisplayOrder { get; set; }
          public string QuestionHelp { get; set; }
          public bool isActive { get; set; }
          public int CategoryID { get; set; }
          public int ProcessID { get; set; }
  
          public virtual Category Category { get; set; }
          public virtual Process Process { get; set; }
          public virtual ICollection&lt;Assessment&gt; Assessment { get; set; }
          public virtual ICollection&lt;Answer&gt; Answers { get; set; }
      }
  
  public class Answer
      {
          public int ID { get; set; }
          public int Value { get; set; }
          public int QuestionID { get; set; }
  
          public virtual Question Question { get; set; }
          public virtual ICollection&lt;Assessment&gt; Assessments { get; set; }
      }
  </code></pre>