这是用于将数据发送到客户端的最佳实践:POCO或DTO?这是、发送到、客户端、数据

2023-09-02 21:43:32 作者:今我来思

我开始使用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.