这是用于将数据发送到客户端的最佳实践:POCO或DTO? [英] What is the best practice for sending data to the client: POCO or DTO?

查看:156
本文介绍了这是用于将数据发送到客户端的最佳实践:POCO或DTO?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开始使用EF 4和POCO的项目。

I'm starting a project using EF 4 and POCO.

这是用于将数据发送到客户端的最佳做法?我应该送POCO或者我应该有一个DTO呢?

What is the best practice for sending data to the client ? Should I send the POCO or I should have a DTO instead?

是否有任何问题,我应该知道发送实体时(即从上下文断开)到客户端?

Are there any issue I should be aware of when sending the entity (that is disconnected from the context) to the client ?

它是一个推荐的做法到POCO发送给客户端层?

Is it a recommended practice to send the POCO to the client layer?

推荐答案

对于我来说,使用EF4与POCO的主要原因之一是,你不是事实的需要的DTO的。我能理解使用DTO的传统EDMX文件,你的实体是pretty的臃肿,但事实并非如此。

For me, one of the main reasons to use EF4 with POCO is the fact that you don't need DTO's. I can understand using DTO's with traditional EDMX files where your entities are pretty bloated, but this isn't the case.

您POCO显然需要可序列化,但真的不应该具体到送不也发生DTO的POCO实体的任何问题。

Your POCO obviously needs to be serializable, but there really shouldn't be any issues specific to sending POCO entities that don't also occur with DTO's.

这篇关于这是用于将数据发送到客户端的最佳实践:POCO或DTO?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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