使用WCF服务实体框架4 ... DTO? [英] Using a WCF Service with Entity Framework 4 and...DTO?

查看:214
本文介绍了使用WCF服务实体框架4 ... DTO?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

正如上面我实现一个多层架构,WCF和Entity Framework 4(与POCO)工作描述。由于我已经有持久性的无知与POCO我需要实现DTO或者我可以以纯的方式使用WCF?

As described above I'm implementing a multi-tier architecture to work with WCF and Entity Framework 4 (with poco). Since I'm already have persistence ignorance with POCO I do need implement DTO or I can use WCF in its pure way?

主要报价 - 我确实需要DTO通过网络上的轻量级对象,或者我可以用我的POCO实体

The main quote is - I do need DTO to pass a lightweight object on the network or I can use my POCO entities.

什么你们建议?

推荐答案

它很难回答,除非你定义什么纯方式是什么。我们在谈论SOA纯或WCF纯洁?

Its hard to answer unless you define what the "pure way" is. Are we talking SOA pure or WCF pure?

WCF代理已经是在某种程度上的DTO,因为它们不沿整个服务合同任何业务逻辑带来的。由WCF生成的代理类的顶端创建的DTO的另一层似乎是多余的。

WCF proxies already are DTOs in a way because they do not bring along any business logic across your service contract. Creating another layer of DTOs on top of the proxy classes generated by WCF seems redundant.

要回答的最大的问题是SOA是如何解决这个?。如果你想成为SOA标准的,你不能共享跨服务边界的POCO实体。 SOA就是完全不同的合同。

The biggest question you want to answer is "how SOA is this solution?". You cannot share your POCO entities across service boundaries if you want to be SOA compliant. SOA is all about disparate contracts.

如果你全力以赴基于SOA的比你失去了很多的功能,因为您的Web层将大部分时间是工作类将是愚蠢的代理。你必须重复大量的逻辑,你失去了很多元数据,约定优于配置功能,MVC 2提供。

If you go all SOA based than you lose a lot of functionality because the classes your web tier will be working with most of the time will be stupid proxies. You'll have to repeat a lot of logic and you lost a lot of the "meta data, convention over configuration" functionality that MVC 2 provides.

如果你扔SOA流行语进入碎纸机,你应该做的( http://soafacts.com/ ),那么你就必须跨层可以更容易地共享业务逻辑和元数据信息。如果你的Web服务的只有消费者自己比这个方法可能是你最好的选择。

If you throw the SOA buzzword into the shredder, which you should do ( http://soafacts.com/ ), then you'll have a much easier time sharing business logic and meta data information across tiers. If the only consumer of your web service is yourself than this method is probably your best choice.

这是在那里你可以使用DTO的跨网络发送你的POCO实体代替。唯一的缺点再次,重复的逻辑,以及大量的锅炉板仪式code,什么也不做的。真的取决于你的项目的大小。如果它的小,忘掉DTO的,但如果你有20个开发商20万控制线工作比DTO的可能是值得创建。

This is where you could use DTOs to send across the wire instead of your POCO entities. The only downside is again, repeating logic, and lots of boiler plate ceremonial code that does nothing. Really depends on the size of your project. If its small, forget about DTOs, but if you have 20 developers working with 200,000 LoC than DTOs are probably worth creating.

这篇关于使用WCF服务实体框架4 ... DTO?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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