从 WCF 服务返回 NHibernate 映射类 [英] Returning NHibernate mapping classes from WCF services

查看:23
本文介绍了从 WCF 服务返回 NHibernate 映射类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个处理数据库访问的服务器和一个使用信息的客户端.从客户端到服务器的通信是通过 WCF 服务进行的.

当NHibernate POCO从服务返回时,对象图中的所有对象都被序列化了吗?如果是这样,有没有办法改变它?

我也在考虑不返回 NHibernate POCO,而是返回一个只包含基本信息的对象.

遇到这些情况你会怎么做?

解决方案

使用数据传输对象将数据从服务器移动到客户端.您的业​​务(领域模型)对象不一定要暴露在应用核心之外,而应被视为受保护的资产.

您可以使用 AutoMapper 自动将业务对象转换为数据传输对象.>

I have a server that handles the database access and a client that consumes the information. The communication from the client to the server is through a WCF service.

When the NHibernate POCO is returned from the service are all the objects in the object graph serialized? If so, is there a way to change it?

I'm also thinking of not returning the NHibernate POCO and instead return an object with only the essential information.

What do you do in these cases?

解决方案

Use data-transfer objects to move the data from the server to the client. Your business (domain model) objects should not necessarily be exposed outside the core of the application, but should be considered a protected asset.

You can use AutoMapper to automate the translation from business objects to data-transfer objects.

这篇关于从 WCF 服务返回 NHibernate 映射类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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