Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8626835
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T08:07:37+00:00 2026-06-12T08:07:37+00:00

I have an ObservableCollection private static CertOrigin_Entities db = new CertOrigin_Entities(); private static ObservableCollection

  • 0

I have an ObservableCollection

private static CertOrigin_Entities db = new CertOrigin_Entities();
private static ObservableCollection ocSHIPPING_DTL;

I have a WPF Datagrid that I do late binding on

    private void btn_SEARCH_Click(object sender, RoutedEventArgs e)
    {
        string sCI = this.txt_SEARCH.Text;

        var sd = (db.TBL_SHIPPING.Where(x => x.CommercialInvoiceNumber == sCI)).ToList();
        if (sd.Count() > 0)
        {
            iID = (int)sd[0].SHIPPING_ID;
            var query = (db.v_wpf_cert_origin.Where(x => x.SHIPPING_ID == iID));
            ocSHIPPING_DTL = new ObservableCollection<v_wpf_cert_origin>(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();
        }
    }

I am updating the SQL server database
behind a button and on the window close

    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;
        }
    }

Here is what is happening to me…
In my datagrid, I have a textbox

                <DataGridTemplateColumn Header="Hs Tarriff Class #:" Width="125" IsReadOnly="False">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <TextBox Text="{Binding Path=HsTarriffClassNumber, 
                                UpdateSourceTrigger=PropertyChanged, 
                                NotifyOnTargetUpdated=True}" 
                                     Name="txt_HsTarriffClassNumber" 
                                      />
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>

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.

The primary issue of the change is this.
I have 3 triggers on the table

1 – After update Audit trigger that takes the deleted and inserts it into another database

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

3 – On Update trigger that updates a different table and sets the last_used_tarrif field equal to the value the user changed.

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?

Can I compare the records in the observable collection to the records in the table and only update those that are actually different?

Any advice?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T08:07:38+00:00Added an answer on June 12, 2026 at 8:07 am

    Because you have the UpdateSourceTrigger set to PropertyChanged (see MSDN: Binding.UpdateSourceTrigger, every time it detects a change, it will action a change.

    Changing from 5864.193.45 to 5864.193.46 is one action, then 5864.193.46 to 5864.193.45 is another action.

    Process 1:
    You could also change UpdateSourceTrigger to LostFocus (UpdateSourceTrigger=LostFocus), this makes it so that the change doesn’t get actioned until you click somewhere else. This way when you change from 5864.193.45 to 5864.193.46 , then 5864.193.46 to 5864.193.45 it wouldn’t action the change until you leave that text area.

    Process 2:
    You could always implement a master ObservationCollection and then only compare when you call _SaveChanges().

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have following code private static ObservableCollection<myColor> myItems = new ObservableCollection<myColor>(); myItems.Add(new myColor(red)); When
I have an ObservableCollection of addresses that I am binding to a ListBox. Then
In my code I have the two following collections: private ObservableCollection<Job> listOfJobs1 = new
I'm new to multithreading and WPF. I have an ObservableCollection<RSSFeed> , at app startup
I have an ObservableCollection that is bound to a DataGrid where I want the
I have an 'ObservableCollection' that stores formatted ColumnLabels that need pasting into DataGrid. The
I have a CollectionView derived from an ObservableCollection : private static ObservableCollection<CalculationViewModel> _calculations; CalculationViewModelsCollection
I have a collection private ObservableCollection<Contact> _contacts; In the constructor of my class I
So i have something along the lines of private ObservableCollection<ViewModel> _internal; public ObservableCollection<ViewModel> BoundInternal{get;set};
Well, I have the following class definitions: private ObservableCollection<Node> _Nodes; public ObservableCollection<Node> Nodes {

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.