title: C# Custom Comparer with Comparison delegate
body: <p>I'm trying to sort a custom BindingList. But i came across the problem that my Comparer does not recognize the properties of my class.
  The "x.Code_PK_OriginalValue" is not recognized. The weird thing is that intellisense marks "Begrenzingen" in Comparer class different as "Begrenzingen" in the first code block beneath.</p>
  
  <pre><code>BindingListX&lt;Begrenzingen&gt; lst = new BindingListX&lt;Begr.....;
  
  lst.OrderBy(t =&gt; t, new CustomComparer&lt;Begrenzingen&gt;());
  </code></pre>
  
  <p>.</p>
  
  <pre><code>public class CustomComparer&lt;Begrenzingen&gt; : IComparer&lt;Begrenzingen&gt;
  {
      private readonly Comparison&lt;Begrenzingen&gt; _comparison;
  
      public CustomComparer()
      {
          _comparison = new Comparison&lt;Begrenzingen&gt;(
                              (Begrenzingen x, Begrenzingen y) =&gt;
                              {
                                  return x.Code_PK_OriginalValue.CompareTo(y.Code_PK_OriginalValue);
                              }
                        );
      }
  
      public int Compare(Begrenzingen x, Begrenzingen y)
      {
          return _comparison(x, y);
      }
  }
  </code></pre>
  
  <p> .</p>
  
  <pre><code>public class BindingListX&lt;T&gt; : BindingList&lt;T&gt;
  {
      public void OrderBy(Func&lt;T,T&gt; keySelector, IComparer&lt;T&gt; comparer)
      {
          this.Items.OrderBy(keySelector, comparer);
      }
  }
  </code></pre>
  
  <p>.</p>
  
  <pre><code>public class Begrenzingen : DefaultTable, IComparable&lt;Begrenzingen&gt;
  {
      public Begrenzingen()
      { //New -&gt; Insert DB
          Code_PK_OriginalValue = -1;
          isDeleted = false;
      }
  
      public decimal Code_PK_OriginalValue { get; set; }
      public decimal Code_PK { get; set; }
      public string Naam { get; set; }
      public decimal? SeqLayer { get; set; }
  
      public Boolean isDeleted { get; set; }
  
      public string SeqLayerDisplayValue { 
          get {
              if (SeqLayer == null) return string.Empty;
              return (from sdo in MainWindow.Main.SdoLayers where sdo.SeqLayer == this.SeqLayer select sdo.DisplayValue).First();
          } 
      }
  
  
      public override string ToString()
      {
          return String.Format("{0};{1};{2};{3}", Code_PK_OriginalValue, Code_PK, Naam, SeqLayer);
      }
  
      public int CompareTo(Begrenzingen o)
      {
          return Code_PK.CompareTo(o.Code_PK);
      }
  }
  </code></pre>