将 NHibernate 与 3 层开发混合

发布于 2024-08-09 00:48:10 字数 391 浏览 0 评论 0原文

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

我使用NHibarnate(Fluent)作为应用程序服务器层的数据源 (应用程序服务器 - 第二层使用 NH 与数据库通信)

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

我是否从使用 NH 中受益 - 因为 WCF 不支持 NH 延迟加载(至少它看起来不像这样)并且 - 如果我使用静态会话对象 - 我必须使服务器单实例单并发 - 否则当多个电话同时打来时,NH 内部的情况就会变得混乱。如果我为每个调用打开一个会话对象 (NH) 并在调用结束时关闭它 - 我会丢失 NHibarante 一级缓存...

所以 - 问题是 - 我实施 NH 是否错误?或者它在我的项目中不应该是有效的吗?

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 ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

恰似旧人归 2024-08-16 00:48:10

您可能需要查看 uNhAddIns WCF 项目。它使用每次调用会话,因为这是使用 WCF 的推荐方法。

您的说法是正确的,没有通过 WCF 进行延迟加载。您需要将对象图填写到您需要的级别,然后将其发送。如果您的服务层在行为上不是面向对象的,NHibernate 可能就有点过分了。如果没有更多背景信息,这是一个艰难的决定。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文