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

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

问题描述

nhibernate代理是否可以做一些聪明的工作来使变更跟踪高效?还是仅支持Entity Framework所谓的基于快照的更改跟踪?

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[].

刷新时,当前状态会转换为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天全站免登陆