Assuming you are comfortable working with XML and the NHibernate configuration itself, there is one object that you need to make a singleton, i.e. an API ISessionFactory. The reason for this is that the full configuration regarding your connection, as well as all object mappings, are loaded into memory, so NHibernate knows how and where it will be stored in the underlying data warehouse. Therefore, the API is a ISessionFactoryvery expensive instance.
As for sessions, there are two aspects to consider: whether you want a session without state or state. This choice is entirely yours, but know the difference.
API ISession . - , , , NHibernate, , , , , . , , API . , , . API ISession API ITransaction. ITransaction, , , Begin Transaction, SQL (TSQL, PL/SQL ). , , , , , . API ISession . API ISession . , API ISession, - , ISession , . API ISession , , .
API IStatelessSession , . , , . , , , . IStatelessSession API ITransaction, . . IStatelessSession , , "" . API , , -, .
, API ISession IStatelessSesion, .