自我跟踪实体和POCO之间的区别 [英] Difference between self tracking entities and POCO

查看:109
本文介绍了自我跟踪实体和POCO之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您是否知道POCO和自我跟踪实体之间的区别是什么?持久性无知是什么意思??

在此先感谢.....:)

Do you have any idea what is difference between POCO and self tracking entities and what is meant by persistance ignorance???

Thanks in advance.....:)

推荐答案

自我跟踪实体不是POCO.相反,它们非常具有持久性.甚至比EntityObject实体还要多.使它们与众不同的原因在于,即使未将这些更改附加到ObjectContext,也可以跟踪更改.

正如您所说,纯" POCO使变更跟踪变得困难.确实,您唯一可以做的就是比较对象的快照.对象上下文为此具有一个DetectChanges方法.

使用伪POCO代理,您真正拥有的是在编译时看起来(几乎)像POCO,在运行时看起来像非POCO的类型.我说几乎"是因为在运行时您将获得一个实例,该实例是编译时类型的子类型.因此,要跟踪其更改的任何属性都必须是非私有的并且是虚拟的.类似的限制适用于延迟加载.您可以在ADO.NET团队博客上的此系列文章中了解有关此内容的更多信息.
Self tracking entities are not POCOs. On the contrary, they are very much persistence-aware. More so than EntityObject entities, even. What makes them unique is the changes can be tracked even when they are not attached to an ObjectContext.

"Pure" POCOs, as you say, make change tracking difficult. Really, the only thing you can do is compare snapshots of the object. The object context has a DetectChanges method for this.

With a pseudo-POCO proxy, what you really have is a type which looks (almost) like a POCO at compile time and like a non-POCO at runtime. I say "almost" because at runtime you will get an instance which is a subtype of the compile-time type. Because of this, any properties for which you want to track changes must be non-private and virtual. Similar restrictions apply to lazy loading. You can read more about this in this series of articles on the ADO.NET team blog.


这篇关于自我跟踪实体和POCO之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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