title: Union Lists using IEqualityComparer
body: <p>I'we got two Lists of my class Nomen: </p>
  
  <pre><code>var N1 = new List&lt;Nomen&gt;(); 
  var N2 = new List&lt;Nomen&gt;(); 
  
  
  public class Nomen
  {
      public string Id;
  
      public string NomenCode;
  
      ...
  
      public string ProducerName;
  
      public decimal? minPrice;
  }
  </code></pre>
  
  <p>I need to join them. I used to do it like this:</p>
  
  <pre><code>result = N2.Union(N1, new NomenComparer()).ToList();
  
  class NomenComparer : IEqualityComparer&lt;Nomen&gt;
  {
      public bool Equals(Nomen x, Nomen y)
      {
          return x.Equals(y);
      }
  
      public int GetHashCode(Nomen nomen)
      {
          return nomen.GetHashCode();
      }
  }
  
      public override int GetHashCode()
      {
          return (Id + NomenCode + ProducerName).GetHashCode();
      }
  
      public bool Equals(Nomen n)
      {
          if (!String.IsNullOrEmpty(Id) &amp;&amp; Id == n.Id) return true;
  
          return (NomenCode == n.NomenCode &amp;&amp; ProducerName == n.ProducerName);
      }
  </code></pre>
  
  <p>As you can see, if Ids or NomenCode and ProducerName are equal, for me it's the same Nomen. 
  now my task have changed and I need to take, if they equal, the one with less minPrice. Please, help me to solve this problem. 
  Tried to do the same with linq, but failed</p>
  
  <pre><code>        var groups = (from n1 in N1
                        join n2 in N2
                        on new { n1.Id, n1.NomenCode, n1.ProducerName } equals new { n2.Id, n2.NomenCode, n2.ProducerName }
                        group new { n1, n2 } by new { n1.Id, n1.NomenCode, n1.ProducerName } into q
                        select new Nomen()
                        {
                            NomenCode = q.Key.NomenCode,
                            ProducerName = q.Key.ProducerName,
                            minPrice = q.Min(item =&gt; item.minPrice)
                        }).ToList();
  </code></pre>
  
  <p>Mostly because I need to join Lists by Ids OR {NomenCode, ProducerName} and I don't know how to do it.</p>