title: Using Linq to group a list of objects into a new grouped list of list of objects
body: <p>I don't know if this is possible in Linq but here goes...</p>
  
  <p>I have an object:</p>
  
  <pre><code>public class User
  {
    public int UserID { get; set; }
    public string UserName { get; set; }
    public int GroupID { get; set; }
  }
  </code></pre>
  
  <p>I return a list that may look like the following:</p>
  
  <pre><code>List&lt;User&gt; userList = new List&lt;User&gt;();
  userList.Add( new User { UserID = 1, UserName = "UserOne", GroupID = 1 } );
  userList.Add( new User { UserID = 2, UserName = "UserTwo", GroupID = 1 } );
  userList.Add( new User { UserID = 3, UserName = "UserThree", GroupID = 2 } );
  userList.Add( new User { UserID = 4, UserName = "UserFour", GroupID = 1 } );
  userList.Add( new User { UserID = 5, UserName = "UserFive", GroupID = 3 } );
  userList.Add( new User { UserID = 6, UserName = "UserSix", GroupID = 3 } );
  </code></pre>
  
  <p>I want to be able to run a Linq query on the above list that groups all the users by GroupID. So the output will be a list of user lists that contains user (if that makes sense?). Something like:</p>
  
  <pre><code>GroupedUserList
      UserList
          UserID = 1, UserName = "UserOne", GroupID = 1
          UserID = 2, UserName = "UserTwo", GroupID = 1
          UserID = 4, UserName = "UserFour", GroupID = 1
      UserList
          UserID = 3, UserName = "UserThree", GroupID = 2
      UserList
          UserID = 5, UserName = "UserFive", GroupID = 3
          UserID = 6, UserName = "UserSix", GroupID = 3
  </code></pre>
  
  <p>I've tried using the groupby linq clause but this seems to return a list of keys and its not grouped by correctly:</p>
  
  <pre><code>var groupedCustomerList = userList.GroupBy( u =&gt; u.GroupID ).ToList();
  </code></pre>