title: Delete rows from a data table that exists in another data table
body: <p>I have a DataTable dt1 with columns C1(PK), C2, and C3(Unique Value) in a DataSet, on which after deleting some rows I will be doing AcceptChanges. I have another DataTable dt2 which is identical in structure to dtA. I would like to delete rows in dtA which exists in dtB compared in terms of C3(unique value) and do the AcceptChanges. </p>
  
  <p>I could achieve very close, but not what I want by doing Except like below (learned from <a href="https://stackoverflow.com/questions/17670668/get-difference-between-two-data-tables-according-to-one-column">here</a>):</p>
  
  <pre><code>var a = dt1.AsEnumerable().Select(r =&gt; r.Field&lt;Guid&gt;("C3"));
  var b = dt2.AsEnumerable().Select(r =&gt; r.Field&lt;Guid&gt;("C3"));
  var c = a.Except(b);
  </code></pre>
  
  <p>Problem with this approach is, I am getting only a list of values that belong in C3 column. I could do some more as shown <a href="https://stackoverflow.com/questions/17670668/get-difference-between-two-data-tables-according-to-one-column">here</a>, but then again I will have a new DataTable, I wont still change the existing dt1 table.</p>
  
  <p>Second approach I thought of was doing something like below:</p>
  
  <pre><code>foreach (DataRow r1 in ds1.Tables[0].Rows)
  {
      foreach(DataRow r2 in dt2.Rows)
      {
          if (r1.Field&lt;Guid&gt;("Guid1") == r2.Field&lt;Guid&gt;("Guid2"))
          {
              r1.Delete();
          }
      }
  }
  </code></pre>
  
  <p>Here as soon as row is deleted, I get an error saying "This row has been removed from a table and does not have any data." What am I missing here?</p>
  
  <p>I also have a feeling that there might be a better way of doing this, just don't know lol.</p>