title: C# linq group by multiple times
body: <p>I have a an object Quiz that looks like :</p>
  
  <pre><code>public class Quiz
  {     
      public int Id { get; set; }          
      public ICollection&lt;MathQuiz&gt; MathQuizzes { get; set; }     
  }
  </code></pre>
  
  <p>MathQuizze object looks like :</p>
  
  <pre><code>public class MathQuiz
  {
  
      public int Id { get; set; }
  
      public int QuizId{ get; set; }
      public Quiz Quiz{ get; set; }
  
      public int AnswerId { get; set; }
      public Answer Answer { get; set; }
  
      public int TagId{ get; set; }
      public Tag Tag { get; set; }
  
      public bool IsCorrect { get; set; }
  
  }
  </code></pre>
  
  <p>And have an object(UserQuizzes) that looks like:</p>
  
  <pre><code>public class UserQuizes
      {
          public int Id { get; set; }
  
  
          public int UserId { get; set; }
          public User User { get; set; }
  
  
          public int QuizId { get; set; }
          public Quiz Quiz { get; set; }
  
  }
  </code></pre>
  
  <p>UserQuizzes is just class that express many to many relationship between users and quizzes.
  This is a sample data : </p>
  
  <pre><code>     List&lt;Quiz&gt; quizzes = new List&lt;Quiz&gt;();
          quizzes.Add(new Quiz{ Id = 1, MathQuizzes = new List&lt;MathQuiz&gt;{ 
                    new MathQuiz { AnswerId = 58, TagId = 1, IsCorrect = false },  
                    new MathQuiz { AnswerId = 26, TagId = 2, IsCorrect = true }, 
                    new MathQuiz { AnswerId = 57, TagId = 3, IsCorrect = true },
  
                    new Quiz{ Id = 2, MathQuizzes = new List&lt;MathQuiz&gt;{ 
                    new MathQuiz { AnswerId = 59, TagId = 1, IsCorrect = false },  
                    new MathQuiz { AnswerId = 87, TagId = 2, IsCorrect = true }, 
                    new MathQuiz { AnswerId = 25, TagId = 3, IsCorrect = true }, });
  
      List&lt;UserQuizzes&gt; userQuizzes = new List&lt;UserQuizzes&gt;();
          userQuizzes.Add(new Quiz{ QuizId = 1, UserId = 1},
          userQuizzes.Add(new Quiz{ QuizId = 2, UserId = 1});
  </code></pre>
  
  <p>Please don't spend too much time criticizing,  I just wanted to use something that everyone is pretty familiar with.</p>
  
  <p>What i want to achieve is that  group by userquizzes by MathQuiz TagId and get data something like this: </p>
  
  <pre><code>TagId : 1, IsCorrect: true(0), false(2);
  TagId : 2, IsCorrect: true(2), false(0);
  TagId : 3, IsCorrect: true(2), false(0);
  </code></pre>