自跟踪实体的目的是什么? [英] What is the purpose of self tracking entities?

查看:292
本文介绍了自跟踪实体的目的是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在阅读有关.NET中的自跟踪实体,以及他们如何可以从* .edmx文件来生成。我正在努力理解的事情是什么产生这些实体可以提供比基本的EF实体?此外,一些人提到自我跟踪实体和Silverlight,但为什么要使用这些,而不是在客户端或赞同RIA服务生成的类?

I've been reading about self-tracking entities in .net and how they can be generated from a *.edmx file. The thing that I'm struggling to understand is what generating these entities gives you over the basic EF entities? Also, some people have mentioned self tracking entities and Silverlight, but why would you use these rather than the client side or shared classes generated by RIA services?

什么是自跟踪实体的点,为什么你会使用他们?

What is the point of self-tracking entities and why would you use them?

推荐答案

自跟踪实体(STE)是实施变更集(previous .NET实现的更改集是数据集)。 STE和其他实体类型(POCO,EntityObject)之间的区别是,常见的实体类型可以跟踪仅当连接到活 ObjectContext的的变化。一旦共同的实体分离它丢失任何变化的跟踪能力。这是STE解决​​什么。 STE能够即使从的ObjectContext 取下它来跟踪变化。

Self tracking entities (STE) are implementation of change set (previous .NET implementation of change set is DataSet). The difference between STE and other entity types (POCO, EntityObject) is that common entity types can track changes only when connected to living ObjectContext. Once common entity is detached it loose any change tracking ability. This is exactly what STE solves. STE is able to track changes even if you detach it from ObjectContext.

STE的常见的用法是在断开的场景,如.NET来过Web服务.NET沟通。首先要求Web服务将创建并返回STE(实体分离时只系列化,的ObjectContext 生活服务于单一的通话)。客户端将改变科技教育,并将其传递回另一个Web服务调用。服务将能够处理的变化,因为这将有STE内部变化跟踪可用。

The common usage of STE is in disconnected scenarios like .NET to .NET communication over web services. First request to web service will create and return STE (entity is detached when serialized and ObjectContext lives only to serve single call). Client will make changes in STE and pass it back in another web service call. Service will be able to process changes because it will have STE internal change tracking available.

处理这种情况下没有变化的跟踪是可能的,但它要复杂得多尤其是当你的工作与整个对象图,而不是单一的实体 - 你必须<一个href="http://stackoverflow.com/questions/3635071/update-relationships-when-saving-changes-of-ef4-poco-objects/3635326#3635326">manually合并从客户数据库中收到的当前状态的变化。

Handling this scenario without change tracking is possible but it is much more complex especially when you work with whole object graph instead of single entity - you must manually merge changes received from client to current state in database.

请注意,<一个href="http://stackoverflow.com/questions/3814706/self-tracking-entities-vs-poco-entities/3815968#3815968">STEs是不是可互操作的解决方案的,因为他们的功能是基于服务器和客户端之间共享STE code。

Be aware that STEs are not for interoperable solutions because their functionality is based on sharing STE code between server and client.

这篇关于自跟踪实体的目的是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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