实体框架和DTO [英] Entity Framework and DTO
问题描述
林计划使用的EF(POCO)产生的实体在将数据发送到客户端,而不是创建的DTO?这是一个好的做法呢?基本上,我的EDMX文件是我的DAL层上。
所以UI会对我DAL直接访问。谢谢你。
Im planning to use the Entities generated by the EF (POCO) in sending data to the client instead of creating DTOs? Is this a good practice? Basically, my EDMX file is on my DAL layer. So the UI will have direct access on my DAL. Thanks.
推荐答案
基本上,我不认为这是DAL对象发送到你的界面是一个好主意,所以我会用DTO的。为了尽量减少努力这样做我会以看一看的 DTO发电机,生成DTO的代码,让您从DAL对象转换为DTO,反之亦然。
Basically, I don't think it's a good idea to send DAL objects to your interface, so I would use DTOs. To minimize the effort doing so I would take a look at an DTO generator, to generate DTO code which lets you convert from DAL object to DTO and vice versa.
编辑:对不起,没看到你正在使用POCO。看看这个 SO帖子
Sorry, didn't see you are using POCO. Have a look at this SO post
这篇关于实体框架和DTO的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!