title: C# Linq Group by with Distinct not working
body: <p>I've reviewed numerous articles here on SO about how to group by using a LINQ statement on a list object but the following code fails to group anything even though all the variables have the exact same values. Could someone please tell me why this might not be working? Does it have something to do with LINQ deferred execution? I've tried a sample where I included a second select statement which did not help. I'm passing in a <code>list&lt;MyClass&gt;</code> object which has two identical items and one that is not, so when this statement executes I should receive back only two items. </p>
  
  <p>Actual values in the code: </p>
  
  <pre><code>   Type = 1, Capacity = 50, Goal = "Teach algebra", 
     Attachments = "", Hours = 1, TypeDesignation = 3, 
     TypeControl = 1, Supplies = 0 
  
     TypeControl and Supplies are both objects themselves. Supplies is empty.
     TypeControl contains Id = 23, Text = "Math", Active = 1
  
          var test = newclass.GroupBy(n =&gt; new 
          {
              n.Type,
              n.Capacity,
              n.Goal,
              n.Attachments,
              n.Hours,
              n.TypeDesignation,
              n.TypeControl,
              n.Supplies
  
          }).Distinct().Select(n =&gt; new MyClass()
          {
              Type = n.Key.Type,
              Capacity = n.Key.Capacity,
              Goal = n.Key.Goal ,
              Attachments = n.Key.Attachments,
              Hours = n.Key.Hours ,
              TypeDesignation = n.Key.TypeDesignation,
              TypeControl = n.Key.TypeControl,
              Supplies = n.Key.Supplies
          });
  </code></pre>