title: GroupBy on complex object (e.g. List<T>)
body: <p>Using <code>GroupBy()</code> and <code>Count() &gt; 1</code> I'm trying to find duplicate instances of my class in a list.</p>
  
  <p>The class looks like this:</p>
  
  <pre><code>public class SampleObject
  {
      public string Id;
      public IEnumerable&lt;string&gt; Events;
  }
  </code></pre>
  
  <p>And this is how I instantiate and group the list:</p>
  
  <pre><code>public class Program
  {
      private static void Main(string[] args)
      {
          var items = new List&lt;SampleObject&gt;()
          {
              new SampleObject() { Id = "Id", Events = new List&lt;string&gt;() { "ExampleEvent" } },
              new SampleObject() { Id = "Id", Events = new List&lt;string&gt;() { "ExampleEvent" } }
          };
  
          var duplicates = items.GroupBy(x =&gt; new { Token = x.Id, x.Events })
                           .Where(g =&gt; g.Count() &gt; 1)
                           .Select(g =&gt; g.Key)
                           .ToList();
      }
  }
  </code></pre>
  
  <p>The <code>duplicates</code> contains no items. How can I make the grouping work?</p>