Managing a FluentNHibernate Session in ASP.NET

New to NHibernate (my disclaimer). I came across a similar and interesting article on MVC , however I am more curious about what general guidelines for managing NHibernate sessions are in a general web application.

I came across the Burrow project , but I'm starting to realize that there seem to be several different directions to take. I know that it is probably not in my interests to create a new SessionFactory every time I need to touch the database, so I am interested in what the community does to manage sessions. Do you use Burrow? Are you wrapping your SessionFactory in a singleton?

Any direction or understanding is always welcome.

+3
source share
2 answers

To answer your question directly, your object ISessionFactorymust be single. You can do this programmatically (i.e. wrap it in single-line C #) or configure it in an IoC container.

, Burrow , - - OpenSessionInView - NHibernate 2.0.0. ISessionFactory.GetCurrentSession(), ISessionFactory.OpenSession(). , factory, ICurrentSessionContext. NHibernate -. " " .

, - .., - , NHibernate .

+5

, NHibernate/Fluent NHibernate.

NHibernate.

NHiberate

"Session for Business Conversation", , NH , , , , , , .

PostSharp IoC

, PostSharp AOP (Aspect Orientated Programming) , Linfu.AOP AOP.

+2

Source: https://habr.com/ru/post/1717747/


All Articles