首页 新闻 会员 周边 捐助

关于实体的当前值和原始值

0
悬赏园豆:50 [已解决问题] 解决于 2012-04-23 23:53

我想知道,通过上下文从数据库获取数据,entry的当前值和原始值,和数据库的当前值和原始值一样还是,entry的当前值和原始值都是数据库的当前值?

 

按照下面的描述,应该是第二种情况,可是我还是想确定一下

When you use the ApplyCurrentValues method in the disconnected scenario, you
query for the current data in the database and then apply your changes. This means
the original values of the entry are those read by the database. When you call Apply-
CurrentValues, the current values in the entry are modified but the original values
(which are those read from the database) aren’t.
Here a big problem arises. When you invoke SaveChanges, the generated WHERE
clause uses the original value of the Version property, which holds the current database
value. The consequence is that the database’s current value is used in the WHERE
clause, causing the data to be modified even if it has since been changed by someone
else.

冻结的眼的主页 冻结的眼 | 初学一级 | 园豆:157
提问于:2012-04-23 22:54
< >
分享
最佳答案
0

EF会对实体进行跟踪,当一个实体从数据库中取出来时,当前值跟原始值是一样的,一旦后面对这个实体进行了更改,当前值就跟原始值不同了,这里的当前值和原始值是针对EF管理的上下文来说的,跟数据库已经没有什么关系了,数据库只是一个持久化的工具

收获园豆:50
artwl | 专家六级 |园豆:16736 | 2012-04-23 23:00

哈哈,谢谢老师啦,理解深刻些了

冻结的眼 | 园豆:157 (初学一级) | 2012-04-23 23:53
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册