Esempio n. 1
0
        internal static ISessionFactory GetMySQLSessionFactory(ISessionFactoryNHibernate pSessionFacotyBase)
        {
            try
            {
                ISessionFactory _sessionFactory = null;

                pSessionFacotyBase.Config.PersistenceConfig = MySQLConfiguration.Standard

                    #if DEBUG
                    .ShowSql()
                    .UseOuterJoin()
                    .FormatSql()
                    #endif

                .ConnectionString(pSessionFacotyBase.Config.Parameters.ConnectionString);

                var nhbConfig = pSessionFacotyBase.Config.GetDefaultConfiguration();

                if (pSessionFacotyBase.Config.Parameters.GenerateSchema)
                    _sessionFactory = nhbConfig.ExposeConfiguration(
                        c => new SchemaUpdate(c).Execute(true, true))
                        .BuildSessionFactory();
                else
                    _sessionFactory = nhbConfig.BuildSessionFactory();

                return _sessionFactory;
            }
            catch (FluentConfigurationException ex)
            {
                throw ex;
            }
        }
        internal static ISessionFactory GetSQLServer2008SessionFactory(ISessionFactoryNHibernate pSessionFacotyBase)
        {
            try
            {
                ISessionFactory _sessionFactory = null;

                pSessionFacotyBase.Config.PersistenceConfig = MsSqlConfiguration
                    .MsSql2008
                    .IsolationLevel(System.Data.IsolationLevel.ReadCommitted)

                    #if DEBUG
                    //.UseOuterJoin()
                    .FormatSql()
                    .ShowSql()

                    #endif

                    .ConnectionString(pSessionFacotyBase.Config.Parameters.ConnectionString);

                var nhbConfig = pSessionFacotyBase.Config.GetDefaultConfiguration();

                if (pSessionFacotyBase.Config.Parameters.GenerateSchema)
                    _sessionFactory = nhbConfig.ExposeConfiguration(
                        c => new SchemaUpdate(c).Execute(true, true))
                        .BuildSessionFactory();
                else
                    _sessionFactory = nhbConfig.BuildSessionFactory();

                return _sessionFactory;
            }
            catch (FluentConfigurationException ex)
            {
                throw ex;
            }
        }