title: Datatable Comparison of - primary keys is not working
body: <p>I have written a code block which Compares datatable for Scheme differences.</p>
  
  <p>this is the code:</p>
  
  <pre><code>    private static void ValidateSchema(DataTable originalTbl, DataTable otherTbl)
      {           
  
          var primaryKeyDoesNotMatch = originalTbl.PrimaryKey != otherTbl.PrimaryKey;
          if(primaryKeyDoesNotMatch)
          {
              throw new ArgumentException("primary key does not match");
          }
  
          var primaryKeyDoesNotExist = originalTbl.PrimaryKey == null;
          if(primaryKeyDoesNotExist)
          {
              throw new ArgumentException("primary key does not exist");
          }
  
          var otherTableHasAdditionalColumns = (from x in otherTbl.Columns.OfType&lt;DataColumn&gt;() where !originalTbl.Columns.OfType&lt;DataColumn&gt;().Any(y =&gt; y.ColumnName == x.ColumnName) select x).Any();
          if (otherTableHasAdditionalColumns)
          {
              throw new ArgumentException("Other table does have additional columns.");
          }
  
          var columnsAreMissingInOtherTable = (from x in originalTbl.Columns.OfType&lt;DataColumn&gt;() where !otherTbl.Columns.OfType&lt;DataColumn&gt;().Any(y =&gt; y.ColumnName == x.ColumnName) select x).Any();
          if (columnsAreMissingInOtherTable)
          {
              throw new ArgumentException("Other table does not have all the columns.");
          }
  
          var columnDataTypesDoesNotMatch = (from x in otherTbl.Columns.OfType&lt;DataColumn&gt;() where originalTbl.Columns.OfType&lt;DataColumn&gt;().Any(y =&gt; x.DataType != y.DataType) select x).Any();
          if (columnDataTypesDoesNotMatch)
          {
              throw new ArgumentException("Column's data type does not match");
          }
  
      }
  </code></pre>
  
  <p>I also have a Unit test for this which has been implemented to test all these scenarios.</p>
  
  <p>the problem is that even when i test the "columnDataTypeDoesNotMatch" or "columnsAreMissinginOtherTable"  it runs till the first IF statement and tells me "primary key does not match" however they do!</p>
  
  <p>any idea why this happens?</p>
  
  <p>your help is appreciated </p>
  
  <p>tanx in advance.</p>