mixing NHibernate with 3 tier developing

你离开我真会死。 提交于 2019-12-04 02:15:26

问题


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 ?


回答1:


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.



来源:https://stackoverflow.com/questions/1650887/mixing-nhibernate-with-3-tier-developing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!