title: How to get last children records with parent record from database
body: <p>I have database with two tables: 
  <code>Customers (Id PK, LastName)</code> 
  and 
  <code>Orders (Id PK, CustomerId FK, ProductName, Price, etc.)</code></p>
  
  <p>I want to retrieve only customer' <strong>last</strong> orders details together with customer name.
  I use .NET L2SQL but I think it's SQL question more than LINQ question so I post here SQL query I tried:</p>
  
  <pre><code>SELECT [t0].[LastName], (
      SELECT [t2].[ProductName]
      FROM (
          SELECT TOP (1) [t1].[ProductName]
          FROM [Orders] AS [t1]
          WHERE [t1].[CustomerId] = [t0].[Id]
          ORDER BY [t1].[Id] DESC
          ) AS [t2]
      ) AS [ProductName], (
      SELECT [t4].[Price]
      FROM (
          SELECT TOP (1) [t3].[Price]
          FROM [Orders] AS [t3]
          WHERE [t3].[CustomerId] = [t0].[Id]
          ORDER BY [t3].[Id] DESC
          ) AS [t4]
      ) AS [Price]
  FROM [Customers] AS [t0]
  </code></pre>
  
  <p>Problem is that Orders has more columns (30) and with each column the query gets bigger and slower because I need to add next subqueries.</p>
  
  <p>Is there any better way?</p>