DTO 与序列化持久化实体 [英] DTOs vs Serializing Persisted Entities

查看:38
本文介绍了DTO 与序列化持久化实体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很想知道社区对此主题的看法.我最近遇到了一个 NHibernate/WCF 场景(实体在服务层持久化)的问题,并意识到我在这里可能走错了方向.

I'm curious to know what the community feels on this subject. I've recently come into the question with a NHibernate/WCF scenario(entities persisted at the service layer) and realized I may be going the wrong direction here.

我的问题很明显,当在 Web 服务(本场景中为 WCF)后面使用持久对象图(NHibernate、LINQ to SQL 等)时,您是否更喜欢通过网络发送这些实体?或者你会创建一组更轻的 DTO(无循环引用)?

My question is plainly, when using a persistent object graph(NHibernate, LINQ to SQL, etc) behind a web service(WCF in this scenario), do you prefer to send those entities over the wire? Or would you create a set of lighter DTO's(sans cyclic references) across?

推荐答案

DTO.使用 AutoMapper 进行对象到对象的映射

DTOs. Use AutoMapper for object-to-object mapping

这篇关于DTO 与序列化持久化实体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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