title: How to display data in a matrix
body: <p>I have a query that returns Countries and Sectors and percentages for each country by sector in a matrix format. I can't seem to find a linq query that will return the data to display in this format. My data from the database looks like this:</p>
  
  <pre><code>Canada | Education | 20
  Canada | Medical   | 80
  Mexico | Education | 40
  Mexico | Medical   | 60
  </code></pre>
  
  <p>and I need to display it like this:</p>
  
  <pre><code>                   Education | Medical
  Canada                 20    |    80
  Mexico                 40    |    60
  </code></pre>
  
  <p>I need to group on the Country but display the Sectors as columns. Here is my query:</p>
  
  <pre><code>var query = from p in ctx.Programs
                        group p by p.Country.Name into g
                        select new
                        {
                            rowKey = g.Key,
                            rowData = g.Select(s =&gt; new { Sector = s.Sector.NameEng, Percentage = s.BUDGET_PCT })
                        };
              return query;
  </code></pre>
  
  <p>but this doesn't work.</p>