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 4253294
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T04:55:36+00:00 2026-05-21T04:55:36+00:00

In case of conflict, I need to overwrite the values in the database with

  • 0

In case of conflict, I need to overwrite the values in the database with my changes . I found the following article on MSDN that explains how to resolve conflicts using the RefreshMode:

http://msdn.microsoft.com/en-us/library/system.data.linq.refreshmode.aspx

I decided KeepCurrentValues makes sense for my requirement and I also found this page with an example for this mode:

http://msdn.microsoft.com/en-us/library/bb399421.aspx

However when I implemented this the values from the database always overwrote my changes. I tried changing the RefreshMode to OverwriteCurrentValues and KeepChanges and each time the values from the database were saved. My approach was to manually change values in the database while in debug mode in VisualStudio. The code in VS is:

[MyDataContext] db = new [MyDataContext]();
try
{
    [MyLINQType] old = (from o in db.[MyLINQType] where o.ID=1 select o).Single();
    old.IntField = 55;

    // This is where I change the IntField value manually in the database in
    // debug mode to generate the conflict.
    db.SubmitChanges(ConflictMode.ContinueOnConflict);
}
catch (ChangeConflictException)
{
    db.ChangeConflicts.ResolveAll(RefreshMode.KeepCurrentValues);
}

I know that the conflict appears but every time, no matter how I change the RefreshMode, the value 55 is never saved and the changes that I made manually in the database are kept. Is there some trick to achieve the desired result? I have tried generating the conflict from inside the code at first and that didn’t work as expected either. Maybe I didn’t understand how the RefreshMode should work. Any ideas are welcome.

  • 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-05-21T04:55:37+00:00Added an answer on May 21, 2026 at 4:55 am

    You just need to call SubmitChanges again…

    catch (ChangeConflictException)
    {            
        db.ChangeConflicts.ResolveAll(RefreshMode.KeepCurrentValues);  
        db.SubmitChanges(); 
    } 
    

    The conflict resolution method determines the state of the DataContext and not the underlying database.

    KeepCurrentValues means keep all values as they are currently in the DataContext, which means the next call to SubmitChanges will save any changes made by the user, but it will also overwrite any changes made by other users after the data was loaded by the current user.

    KeepChanges means keep only the values that have been changed since being loaded into the DataContext, which means the next call to SubmitChanges will save any changes made by the user and will preserve any changes made by other users. And, if another user changed the same value as the current user, the current user’s change will overwrite it.

    OverwriteCurrentValues means update the DataContext with the current database values, which means that all changes made by the current user will be discarded.

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

Sidebar

Related Questions

Case Currently I'm working on database seeding script, executed with sqlcmd . For example
I'm using CUP to create a parser that I need for my thesis. I
I am struggling with a perceived conflict between tracking all my changes so I
To first give a little bit of context, my use-case is that my partner
Case in point : I've got a handle to a window (for instance, using
Case One: new Date(Date.parse(Jul 8, 2005)); Output: Fri Jul 08 2005 00:00:00 GMT-0700 (PST)
Case example: I have a long list of items, and when I put my
Case One Say you have a little class: class Point3D { private: float x,y,z;
Case i'm trying to write a GWTTestCase for a certain class, used as a
Case with bootstrap: Example code function( $ ){ }( window.jQuery );

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.