title: How to determine if a row in ObservableCollection<T> actually changed
body: <p>I have an ObservableCollection</p>
  
  <p>private static CertOrigin_Entities db = new CertOrigin_Entities();
  private static ObservableCollection ocSHIPPING_DTL;</p>
  
  <p>I have a WPF Datagrid that I do late binding on</p>
  
  <pre><code>    private void btn_SEARCH_Click(object sender, RoutedEventArgs e)
      {
          string sCI = this.txt_SEARCH.Text;
  
          var sd = (db.TBL_SHIPPING.Where(x =&gt; x.CommercialInvoiceNumber == sCI)).ToList();
          if (sd.Count() &gt; 0)
          {
              iID = (int)sd[0].SHIPPING_ID;
              var query = (db.v_wpf_cert_origin.Where(x =&gt; x.SHIPPING_ID == iID));
              ocSHIPPING_DTL = new ObservableCollection&lt;v_wpf_cert_origin&gt;(query.ToList());
  
              dgCOO.ItemsSource = ocSHIPPING_DTL;
  
              var cust = (from x in db.TBL_CUSTOMER
                       join y in db.TBL_REQUISITION on x.CUSTOMER_ID equals y.CUSTOMER_ID
                       join z in db.TBL_SHIPPING on y.REQ_ID equals z.REQ_ID
                       where z.SHIPPING_ID == iID
                       select new {CUST = x.CustomerName}).ToList();
              this.lbl_CUSTOMER.Content = cust[0].CUST.ToString();
          }
      }
  </code></pre>
  
  <p>I am updating the SQL server database
  behind a button and on the window close</p>
  
  <pre><code>    private static bool _SaveChanges()
      {
          DbTransaction _dbTransaction = null;
          db.Connection.Open();
          using (_dbTransaction = db.Connection.BeginTransaction())
          {
              try
              {
                  db.SaveChanges();
                  db.AcceptAllChanges();
                  _dbTransaction.Commit();
                  db.Connection.Close();
              }
              catch (TransactionAbortedException ex)
              {
                  db.Connection.Close();
                  throw ex;
              }
              return true;
          }
      }
  </code></pre>
  
  <p>Here is what is happening to me...
  In my datagrid, I have a textbox</p>
  
  <pre><code>                &lt;DataGridTemplateColumn Header="Hs Tarriff Class #:" Width="125" IsReadOnly="False"&gt;
                      &lt;DataGridTemplateColumn.CellTemplate&gt;
                          &lt;DataTemplate&gt;
                              &lt;TextBox Text="{Binding Path=HsTarriffClassNumber, 
                                  UpdateSourceTrigger=PropertyChanged, 
                                  NotifyOnTargetUpdated=True}" 
                                       Name="txt_HsTarriffClassNumber" 
                                        /&gt;
                          &lt;/DataTemplate&gt;
                      &lt;/DataGridTemplateColumn.CellTemplate&gt;
  </code></pre>
  
  <p>If the text box has 5864.193.45 as the value and I change it to 5864.193.46 then back to 5864.193.45 the ObservableCollection saves the record as the record did change, however I do not want it to save the record as it did not change.</p>
  
  <p>The primary issue of the change is this.
  I have 3 triggers on the table</p>
  
  <p>1 - After update Audit trigger that takes the deleted and inserts it into another database</p>
  
  <p>2 - After Update Audit trigger that sends an email to a multidude of people stating that the user changed the data and they need to reprint the paperwork and send it to customs</p>
  
  <p>3 - On Update trigger that updates a different table and sets the last_used_tarrif field equal to the value the user changed.</p>
  
  <p>If the user did not actually change the data none of the above should fire.
  Is there a way to check if the record actually changed?</p>
  
  <p>Can I compare the records in the observable collection to the records in the table and only update those that are actually different?</p>
  
  <p>Any advice?</p>