将NHibernate与3层开发混合 [英] mixing NHibernate with 3 tier developing

查看:154
本文介绍了将NHibernate与3层开发混合的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个3层的应用程序:
第一层:SQL DB。
第二层:应用服务器(dotnet)
第三层:智能wpf客户端。

我使用NHibarnate(流利)作为数据源为应用程序服务器层
(应用程序服务器 - 第二层使用NH与数据库对话)

应用程序层使用WCF与客户端进行通信。



使用NH的好处是什么?因为WCF不支持NH懒惰加载(至少看起来不像这样),如果我使用静态会话对象,使服务器单实例单一并发 - 否则当多个呼叫同时发生时,NH内部会变得混乱。如果我为每个调用打开一个会话对象(NH),并在调用结束时关闭它 - 我将释放NHibarante一级缓存...


$ b 问题是 - 我在执行NH吗?或者是不是假设在我的这种项目中是有效率的?

您可能想要查看 uNhAddIns WCF项目。它使用session-per-call,因为这是WCF推荐的方式。



你说WCF没有延迟加载是正确的。您需要填写对象图到您需要的级别,然后发送它的方式。如果你的服务层不是面向对象的行为NHibernate可能是矫枉过正。没有更多的上下文,这是一个艰难的决定。

I have a 3 tiered app: 1st layer: SQL DB. 2nd layer: App Sever (dotnet) 3rd layer: smart wpf client.

I'm using NHibarnate (fluent) as the data source for the application server layer (App server- 2nd layer talks to DB using NH)

Application layer talks to the client using WCF.

Do I benefit anything from using NH - as WCF doesn't support NH lazy loading (at least it doesn't look like this) and - if I use a static session object - I have to make the server single instance single concurrency - otherwise things get messy inside NH when more than one call comes at the same time. If I open a session object (NH) for each call and close it at the end of the call - I loose the NHibarante 1st level cache...

So - The question is - am I implementing NH wrong ? or is it not suppose to be efficient in my kind of project ?

解决方案

You may want to check out the uNhAddIns WCF project. It uses session-per-call, as that is the recommended way to go with WCF.

You are correct in saying that there is no lazy load via WCF. You need to fill out the object graph to the level you need and then send it on its way. If your service layer isn't object oriented in behavior NHibernate may be overkill. That's a tough call without a lot more context.

这篇关于将NHibernate与3层开发混合的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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