문제

I'm a beginner at both NHibernate and Castle Windsor but the current application I'm working on is making use of Castle Windsor's NHibernate facility Integration level 2 i.e. using the ISessionManager.

I've compared what I need to do in order to manually persist my data and using ISessionManager and I'm not really writing less code. My question is why do I even need ISessionManager? What advantages is it offering me? What are the disadvantages of using ISessionManager?

도움이 되었습니까?

해결책

Well first of all, you don't have to manage sessions yourself. In a web-enviroment you typically want to scope your sessions pr request. The session manager ensures that the first caller to "OpenSession" starts a new session, while nested invocations gets the same session when invoking "OpenSession". You can do the same yourself by staring/closing sessions in a httpmodule or using an AOP pattern, note that doing this implies that your are working against one database, handling multiple databases yourself gets a bit more tedious. ISessionManager handles multiple databases just as tidy as it handles one.

+ Handles sessions for you Lightweight, non intrusive Simple Easy support for working against multiple databases Hosting agnostic (works just as well with nservicebushosting as it does with IIS)

- A bit more boilerplate code in your DAL/Repositories/whatever you call it

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top