title: C# SQL parent child table select query help
body: <p>I have two tables that I want to fetch data from.</p>
  
  <p>Lets call them "Parent" and "Children". The "Parent" table has many records in the "Children" table. (One to Many)</p>
  
  <p>My problem is I want to find an efficient method for displaying the data the two tables contain to my ASP.NET MVC application. My approach is to select all records from "Parent" then loop through each one selecting the data from "Children".</p>
  
  <p>So I need help designing a query for SQL Server 05 that can get the data out for C# more efficiently, I was planning of creating type classes and the "Parent" class would have a "List" that in my View I can loop through outputting the values.</p>
  
  <pre><code>public class Parent_Type
  {
      public string Name { get; set; }
      public List&lt;Children_Type&gt; Children { get; set; }
  }
  
  
  public class Children_Type
  {
      public string Name { get; set; }
  }
  </code></pre>
  
  <p>The data needs to be displayed like: (The name of the "Parent" record then a list of "Children" records")</p>
  
  <p>"Parent 123"</p>
  
  <ul>
  <li>"Child 1" </li>
  <li>"Child 2"</li>
  <li>"Child 3"</li>
  </ul>
  
  <p>"Parent 124"</p>
  
  <ul>
  <li>"Child 1" </li>
  <li>"Child 2"</li>
  <li>"Child 3"</li>
  </ul>