title: How to use the IEqualityComparer
body: <p>I have some bells in my database with the same number. I want to get all of them without duplication. I created a compare class to do this work, but the execution of the function causes a big delay from the function without distinct, from 0.6 sec to 3.2 sec!</p>
  
  <p>Am I doing it right or do I have to use another method?</p>
  
  <pre><code>reg.AddRange(
      (from a in this.dataContext.reglements
       join b in this.dataContext.Clients on a.Id_client equals b.Id
       where a.date_v &lt;= datefin &amp;&amp; a.date_v &gt;= datedeb
       where a.Id_client == b.Id
       orderby a.date_v descending 
       select new Class_reglement
       {
           nom  = b.Nom,
           code = b.code,
           Numf = a.Numf,
       })
      .AsEnumerable()
      .Distinct(new Compare())
      .ToList());
  
  class Compare : IEqualityComparer&lt;Class_reglement&gt;
  {
      public bool Equals(Class_reglement x, Class_reglement y)
      {
          if (x.Numf == y.Numf)
          {
              return true;
          }
          else { return false; }
      }
      public int GetHashCode(Class_reglement codeh)
      {
          return 0;
      }
  }
  </code></pre>