Datacontext submitchanges not updating database
So my assumption that the Data Context instances are the same was incorrect.So, in my class with the Singleton lifetime, I get a fresh instance of the database repository and perform the update and no problem.See You could then use something like the code below to output the SQL to the Visual Studio Debug window while debugging.
I have a decimal column in my database called Units, anytime I set the value of the column to a NON ZERO, and Submit Changes the column updates with the new value. Solution I figured out my problem with the help of the SO community. I suggest you to create a such simple repro with your domain model and see what happens.
I've even refreshed the object from the database using the Data Contact. The initial insert is being performed in a service class with a Per Web Request lifetime.
Refresh method before it is pulled for the update, but that didn't help. The select and update is happening in a class with a Singleton lifetime.
Regardless of how many changes you make to your objects, changes are made only to in-memory replicas.
You have made no changes to the actual data in the database.Then, in the same web request, I pull that same record, and update it, then submit changes. The Database Context is the same across both these operations.Insert: ITransaction transaction = _transaction Repository. Find By Id(transaction Id); if (transaction == null) throw new Exception(Constants. Format With(transaction Id)); using (IUnit Of Work unit Of Work = Unit Of Work.Your changes are not transmitted to the server until you explicitly call Submit Changes on the Data Context.