예제 #1
0
        public void SubmitAndMergeChanges()
        {
            try
            {
                SubmitChanges(ConflictMode.ContinueOnConflict);
            }

            catch (ChangeConflictException)
            {
                // Automerge database values for members that client has modified
                ChangeConflicts.ResolveAll(RefreshMode.KeepChanges);

                // Submit succeeds on second try.
                SubmitChanges();
            }
        }
예제 #2
0
        public void SafeSubmitChanges()
        {
            try
            {
                SubmitChanges(ConflictMode.ContinueOnConflict);
            }
            catch (ChangeConflictException)
            {
                // ChangeConflicts.ResolveAll(RefreshMode.KeepCurrentValues); //保持当前的值
                // ChangeConflicts.ResolveAll(RefreshMode.OverwriteCurrentValues); //保持原来的更新,放弃了当前的值.
                ChangeConflicts.ResolveAll(RefreshMode.KeepChanges); //保存原来的值 有冲突的话保存当前版本

                // 注意:解决完冲突后还得 SubmitChanges() 一次,不然一样是没有更新到数据库的
                SubmitChanges();
            }
        }