public static ISession GetCurrentOrNewSession(this ISessionFactory sessionFactory, ICurrentSessionContextBinder currentSessionContextBinder = null, Action <ISession> onSessionOpened = null) { currentSessionContextBinder = currentSessionContextBinder ?? sessionFactory.GetDefaultCurrentSessionContextBinder(); if (currentSessionContextBinder.HasBind(sessionFactory)) { return(sessionFactory.GetCurrentSession()); } var session = currentSessionContextBinder.BindNew(sessionFactory); if (onSessionOpened != null) { onSessionOpened(session); } return(session); }
protected virtual ICurrentSessionContextBinder GetCurrentSessionContextBinder(ISessionFactory sessionFactory) { return(sessionFactory.GetDefaultCurrentSessionContextBinder()); }