title: LINQ Group Rows Into Columns
body: <p>How can I group an up to 7 number of rows into a single row where the set columns determine the grouping?</p>
  
  <p>I dont have fix rows.</p>
  
  <p>I saw Stack overflow already has this question but answer is in SQL.</p>
  
  <p>I need LINQ. I dont know how can I achieve this ?</p>
  
  <p>Please have a look at StackOverflow link below </p>
  
  <p><a href="https://stackoverflow.com/questions/10652921/t-sql-group-rows-into-columns">T- SQL group rows into columns</a></p>
  
  <pre><code>Table 
  
  Id  RefId  Name   
  ------------------------
   1    1    Test1    
   2    1    Test2    
   3    1    Test3    
   4    2    Test4    
   5    2    Test5    
  </code></pre>
  
  <p>So, Output would be ..</p>
  
  <pre><code>RefId  Name1  Name2  Name3  Name4 Name5 Name6 Name7  Id1 Id2 Id3 Id4  Id5  Id6  Id7
  -----------------------------------------------------------------------------------
   1     Test1  Test2  Test4  null  null  null  null   1   2   3   null null null null
   2     Test4  Test5   null  null  null  null  null   4   5  null null null null null
  </code></pre>
  
  <p>Here, it is fixed that rows comes up to 7 .. not more than that</p>