是否建议将自跟踪实体与 WCF 服务一起使用? [英] Is it recommended to use Self Tracking Entities with WCF services?

查看:26
本文介绍了是否建议将自跟踪实体与 WCF 服务一起使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道 WCF 服务是否推荐使用 Self Tacking Entities(在实体框架中)?如果是,那么您能否指导我学习可以指导如何做到这一点的教程?

I want to know if using Self Tacking Entities (in Entity Framework) is recommended with WCF services? If yes, then can you guide me to a tutorial which may guide how to do that?

实际上,我将使用带有 MEF 和 MVVM 的 Prism 开发 WPF 应用程序.我决定使用实体框架.我想要关于这种方法的建议和建议.

Actually, I am going to develop a WPF application using Prism with MEF and MVVM. I have decided to use Entity Framework. I want suggestions and advices regarding this approach.

任何帮助将不胜感激.

推荐答案

我想知道是否使用 Self Tacking Entities(在实体框架中)推荐使用 WCF 服务?

I want to know if using Self Tacking Entities (in Entity Framework) is recommended with WCF services?

这取决于你问谁.如果你问 MS,他们会告诉你是的,因为他们根本没有更好的东西可以提供.STE 是对这个非常古老的MS Connect 建议.问题是 EF 本身有糟糕的支持 合并两个实体图之间的变化(你必须完全自己做)和在 MS 平台上工作的开发人员(有时包括我)有一些共同的行为:

It depends who you ask. If you ask MS they will tell you Yes because they simply don't have anything better to offer. STEs were response to this very old MS Connect suggestion. The problem is that EF itself has terrible bad support for merging changes between two entity graphs (you must do it completely yourselves) and developers working on MS platform (sometimes including me) share some common behaviors:

  • 他们懒得开发自己的问题解决方案,他们期望直接在 MS 提供的 API 中使用一些魔法.
  • 大多数时候,他们在必须使用的技术方面未受过培训/熟练/胜任,因为他们不得不经常转向新的技术.
  • 他们知道的唯一 API 是 .NET Framework 的一部分.他们不寻找其他选项,也不比较功能.

前两点是 MS 策略的结果,其中 RAD 成为设计器(或新的 T4 模板)的同义词.

First two points are result of MS strategy where RAD become synonym for designer (or newly also T4 templates).

分享@Richard 对 STE 的看法.我要添加 STE 的另一个缺点——它们在参与者之间移动大型数据集.如果您决定从服务器获取实体图,请更改图中的单个实体并将数据推回,它们将再次传输整个图.仅传输更改的实体会导致与 STE 的核心逻辑发生冲突.我也担心他们会在每个实体级别而不是每个财产级别完全跟踪更改.如果修改具有大量二进制或字符串数​​据的实体,可能会导致在服务和数据库之间以及服务和客户端之间传输过多不需要的数据.

I share @Richard opinion about STEs. I would add one additional drawback of STEs - they move large datasets between participants. If you decide to get an entity graph from the server, change a single entity in the graph and push data back they will transfer again the whole graph. Transferring only changed entities results in fighting with STE's core logic. I'm also afraid that they track changes completely on per entity level instead of per property level. In case of modification to entities with large binary or string data it can result in transferring too much unneeded data between the service and the database and between the service and the client.

无论如何,对于具有低数据流量和小型实体的简单应用程序,它们可以做得很好,并允许您快速构建应用程序,但无需严格分离关注点.您将从服务中获取实体并将它们直接绑定到 WPF UI,它们将能够为您跟踪更改.稍后您会将实体推回服务,它们将能够保留更改.您的客户端和服务将紧密耦合,但在某些情况下它可能已经足够好了.

Anyway for a simple application with low data traffic and small entities they can do a good job and allow you building your application quickly but without strict separation of concerns. You will get entities from service and bind them directly to WPF UI and they will be able to track changes for you. Later you will push entities back to service and they will be able to persist changes. Your client and service will be tightly coupled but in some scenarios it can be good enough.

这篇关于是否建议将自跟踪实体与 WCF 服务一起使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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