Spring.Data.NHibernate.SessionFactoryUtils.IsSessionTransactional C# (CSharp) Method

IsSessionTransactional() public static method

Return whether the given Hibernate Session is transactional, that is, bound to the current thread by Spring's transaction facilities.
public static IsSessionTransactional ( ISession session, ISessionFactory sessionFactory ) : bool
session ISession The hibernate session to check
sessionFactory ISessionFactory The session factory that the session /// was created with, can be null.
return bool
        public static bool IsSessionTransactional(ISession session, ISessionFactory sessionFactory) 
        {
            if (sessionFactory == null) 
            {
                return false;
            }
            SessionHolder sessionHolder =
                (SessionHolder) TransactionSynchronizationManager.GetResource(sessionFactory);
            return (sessionHolder != null && sessionHolder.ContainsSession(session));
        }