解决 [英] Resolve

查看:53
本文介绍了解决的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,

DataContext类中有一个名为"&"的方法。解决所有" 。并且该方法采用参数" RefreshMode " 。

我读了这个枚举的描述,但实际上我无法理解它。 desription是:

KeepCurrentValues: 强制 Refresh 方法将原始值与从数据库中检索的值交换。否
修改当前值。


KeepChanges: 强制 Refresh 方法以保持当前已更改的值,但使用<更新其他值br>数据库值。


OverwriteCurrentValues: 强制 Refresh 方法使用数据库中的值覆盖所有当前值。


所以任何人都可以更清楚地解释它们。如果有样本来显示它们之间的差异。

谢谢


ASk

Hello ,

  there is a method in the DataContext Class called " Resolve All " . And This Method take a parameter " RefreshMode " .

  I read a description of this enumeration but Really I cannot understand it .  the desription is :
   
  KeepCurrentValues   :   Forces the Refresh method to swap the original value with the values retrieved from the database. No 
                                              current value is modified. 


 
KeepChanges :     Forces the Refresh method to keep the current value that has been changed, but updates the other values with
                                  the database values. 


OverwriteCurrentValues :  Forces the Refresh method to override all the current values with the values from the database.


So Could anyone explain them more clearly . And If there a sample to show the difference between them .

 Thanks


ASk

推荐答案

因此,假设您在数据库中有一个姓氏为Jones的Employee对象。此对象通过LINQ to SQL加载到内存中,随后将属性修改为Smith,但由于尚未调用SubmitChanges,因此尚未将更改提交回数据库。

LINQ to SQL内部保留原始内容值,以便它可以执行必要的并发检查,以便解决。假设其他人现在已更改此用户并将姓氏更改提交给Adams,每个选项将按如下方式解析:

KeepCurrentValues - "Jones"的原始值。在记忆中现在将是"亚当斯"。因此,如果此字段是并发字段的一部分,则它将成功将数据库从Adams更改为Smith。即使名称最初没有在内存中从Jones更改为Smith,当前值仍将包含Jones。

KeepChanges - 行为与KeepCurrentValues相同但如果内存中的值未更改,则两者都刷新内存中的当前值和原始值。

OverwriteCurrentValues - 内存中的所有值都被丢弃并替换为数据库中的值。

[] amien
So let's say you have an Employee object with a Surname of Jones in the database. This object is loaded into memory via LINQ to SQL and subsequently the property modified to Smith but the changes have not yet been commited back to the database because SubmitChanges has not yet been called.

Internally LINQ to SQL keeps the original values so it can perform the necessary concurrency checks so resolving. Let's say somebody else has now changed this user and commited the surname change to Adams, each option will resolve as follows:
 
KeepCurrentValues - the original value of "Jones" in memory will now be "Adams" so if this field is part of the concurrency field it will successfully change the database from Adams to Smith. Even if the name had not originally been changed in memory from Jones to Smith the current value will still contain Jones.

KeepChanges - behaves the same as KeepCurrentValues but if the in-memory value has not been changed then both the current and original values in memory are refreshed.

OverwriteCurrentValues - all values in memory are discarded and replaced with values from the database.

[)amien


这篇关于解决的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆