title: Linq to Entities - eager loading using Include()
body: <p>I've got this really basic table structure:</p>
  
  <p>dbo.tblCategory
  <br/>
  dbo.tblQuestion (many to one relationship to tblCategory)
  <br/>
  dbo.tblAnswer (many to one relationship to tblQuestion)</p>
  
  <p>So basically, what I'm trying to do is when I load a category, I want to also load all Questions, and all Answers.</p>
  
  <p>Now, I've been able to do this using the following code:</p>
  
  <pre><code>public tblCategory Retrieve(int id)
  {
      using (var entities = Context)
      {
          var dto =
              (from t in entities.tblCategory.Include("tblQuestion")
                                             .Include("tblQuestion.tblAnswers")    
                   where t.Id == id
                   select t).FirstOrDefault();
  
              return entities.DetachObjectGraph(dto);
          }
      }
  }
  </code></pre>
  
  <p>However, I'm not completely enamored with this; if the relationship names change in my model; I'm not going to get a error when building the project.  Ideally, I'd like to use a lambda expression; something like this:</p>
  
  <pre><code>public tblCategory Retrieve(int id)
  {
      using (var entities = Context)
      {
          var dto =
              (from t in entities.tblCategory.Include(t =&gt; t.tblQuestion)
               where t.Id == id
               select t).FirstOrDefault();
  
          return entities.DetachObjectGraph(dto);
      }
  }
  </code></pre>
  
  <p>Now, with the above snippet; I'm stuck on how to drill down to the Answers table.  Any idea on what I could use for a lambda expression for this one?</p>