/// <summary>
        /// Runs an NHibernate query in a transaction.
        /// </summary>
        /// <typeparam name="TOut">The type of the out.</typeparam>
        /// <param name="f">The f.</param>
        /// <param name="isolationLevel">The isolation level.</param>
        /// <returns>The TOut</returns>
        protected TOut RunInTransaction <TOut>(Func <ISession, TOut> f, IsolationLevel isolationLevel = IsolationLevel.Unspecified) where TOut : class
        {
            var session = SessionSource.GetSession();

            using (var trans = session.BeginTransaction(isolationLevel))
            {
                try
                {
                    var result = f(session);

                    if (trans.IsActive)
                    {
                        trans.Commit();
                    }

                    return(result);
                }
                catch (Exception x)
                {
                    if (trans.IsActive)
                    {
                        trans.Rollback();
                    }

                    this.logger.Error("Failed to execute a result in a transaction", x);
                    throw;
                }
            }
        }
        /// <summary>
        /// Runs an NHibernate query in a transaction.
        /// </summary>
        /// <param name="f">The f.</param>
        /// <param name="isolationLevel">The isolation level.</param>
        protected void RunInTransaction(Action <ISession> f, IsolationLevel isolationLevel = IsolationLevel.Unspecified)
        {
            var session = SessionSource.GetSession();

            using (var trans = session.BeginTransaction(isolationLevel))
            {
                try
                {
                    f(session);

                    if (trans.IsActive)
                    {
                        trans.Commit();
                    }
                }
                catch (Exception x)
                {
                    if (trans.IsActive)
                    {
                        trans.Rollback();
                    }

                    this.logger.Error("Failed to run in transaction", x);
                    throw;
                }
            }
        }