title: convert rows into columns in linq
body: <p>I have the following query: </p>
  
  <pre><code>var query = from q1 in lstAgentDetails
              join q2 in lstAgentMaterialPercentage on q1.Agent_Id equals q2.AMP_Agent_Id
              into list1
              from lu in list1.DefaultIfEmpty()
              join q3 in lstMaterialType on lu.AMP_MaterialType_Id equals              q3.MaterialType_Id into list2
                          from l2 in list2.DefaultIfEmpty()
                          select new
                          {
                              q1.Agent_Name
                              lu.AMP_percentage
                              q3.Materialtype_Name
                          };   
              IList iu = query.ToList();
  </code></pre>
  
  <p>The query result is as follows:</p>
  
  <pre><code>agentname  material name     percentage
  agent1     material1         20    
  agent1     material2         10
  agent2     material1         15
  agent1     material3         25
  agent3     material1         10
  agent2     material2         30
  </code></pre>
  
  <p>However, I want the result in the following format:</p>
  
  <pre><code>agentname         material1         material2         material3   ...........
  agent1            20                10                25          ..........
  agent2            15                30                0           ..........
  agent3            10                0                 0           ..........
  </code></pre>
  
  <p>Please help me out.</p>