title: Entity Framework 4: Fetching data of two table and returning to persentation layer
body: <p>I have two tables having 1 to 1 relationship. One table called <code>Person</code> and second is <code>PersonDetails</code>. <code>PesonId</code> is in <code>PersonDetails</code> table as <code>FK</code>.</p>
  
  <p>I can query individual tables like </p>
  
  <pre><code>public static Person GetPersonById(int personId)
  {
      using (var context = new REntities())
      {
      return context.Person.Where(p =&gt; p.PersonId == personId).First();
      }
  }
  </code></pre>
  
  <p>It is being used in consuming code like:</p>
  
  <pre><code>Person personInfo = PersonService.GetPersonById(personId);
  </code></pre>
  
  <p>and same with <code>PersonDetail</code> on its PK i.e. <code>PersonDetailId</code> </p>
  
  <p>But when I have to fetch data from two tables then I am not understanding that what how would I do this and what would be the best way to return data to presentation layer.</p>
  
  <p>Following would be the code to get <code>Person</code> and relate <code>PersonDetails</code> records:</p>
  
  <pre><code>from personData in context.person.Include("PersonDetail")
                                    where personData.PersonId == personId
                                    select personData;
  </code></pre>
  
  <p>What is personData here?
  How can I iterate over it and get each item in client code?</p>
  
  <p>Thanks.</p>