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

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

问题描述

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

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.

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

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?

我还考虑不返回NHibernate POCO,而是返回仅包含基本信息的对象.

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.

您可以使用 AutoMapper 自动执行从业务对象到数据传输对象的转换.

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

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

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