NHibernate 如何实现变更跟踪? [英] How does NHibernate implement change tracking?

查看:18
本文介绍了NHibernate 如何实现变更跟踪?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

nhibernate 代理是否能做任何聪明的工作来提高变更跟踪的效率?还是它只支持实体框架称为基于快照的更改跟踪?

Does nhibernate proxies do any smart job to make change tracking efficient? Or does it only support what Entity Framework calls snapshot based change tracking?

推荐答案

它是基于快照的.

加载实体时,其状态作为对象[]存储在会话中.

When loading an entity, its state is stored in the session as an object[].

flush 时,将当前状态转换为 object[] 并与原始状态进行比较,以确定哪些属性是脏的.

When flushing, the current state is converted to an object[] and compared with the original state to determine which properties are dirty.

出于多种原因,这更有效.其中之一是您不需要需要代理来跟踪更改.另一个是,如果您将一个属性设置为不同的值然后将其还原,则该实体将被视为非脏的,从而避免了不必要的数据库调用.

This is more efficient for many reasons. One of them is that you don't need a proxy to track changes. Another is that, if you set a property to a different value and then revert it, the entity will be considered not-dirty, thus avoiding an unnecessary DB call.

这篇关于NHibernate 如何实现变更跟踪?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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