NHibernate WCF双向和延迟加载 [英] NHibernate WCF Bidirectional and Lazy loading

查看:71
本文介绍了NHibernate WCF双向和延迟加载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

关于NHibernate和WCF,我只是在寻找一些方向.

I'm just looking for some direction when it comes to NHibernate and WCF.

此刻,我在一个人和地址之间有多对一的联系.

At the moment i have a many to one association between a person and address.

第一个问题. 我必须急于加载地址列表,以便它不会生成延迟加载的代理.有没有办法完全禁用延迟加载?我从不希望看到它的产生.

The first problem. I have to eager load the list of addresses so it doesn't generate a lazy loaded proxy. Is there a way to disable lazy loading completely? I never want to see it generated.

第二个问题. 我的poco之间的双向关联正在杀死我的标准序列化.最好的前进方式是什么.我应该删除

感谢您的所有帮助

The second problem. The bidirectional association between my poco's is killing my standard serialization. What's the best way forward. Should I remove the

Thanks for all your help

推荐答案

最好的解决方案是不要在服务中公开持久类.

The best solution is NOT to expose your persistent classes in the service.

相反,创建仅包含每个服务调用所需信息的DTO类,并公开这些信息.

Instead, create DTO classes that contain only the information needed by each service call, and expose those.

您可以使用 AutoMapper 来避免从DTO映射到DTO以及持久化的部分工作.课.

You can use AutoMapper to avoid part of the work of mapping from/to the DTOs and the persistent classes.

这篇关于NHibernate WCF双向和延迟加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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