/// <summary>
        /// Create an NHibernate configuration class.
        /// </summary>
        /// <param name="options">Configuration options.</param>
        /// <returns>The configuration.</returns>
        public NHibernate.Cfg.Configuration CreateNHibernateConfiguration(ConfigurationFlags options)
        {
            var configuration = new NHibernate.Cfg.Configuration();

            if ((options & ConfigurationFlags.Settings) == ConfigurationFlags.Settings)
            {
                configuration.SetProperty("hibernate.connection.connection_string", ConnectionConnectionString);
                configuration.SetProperty("hibernate.connection.provider", ConnectionProvider);
                configuration.SetProperty("hibernate.connection.driver_class", ConnectionDriverClass);
                configuration.SetProperty("hibernate.show_sql",
                                          ShowSql.ToString(CultureInfo.InvariantCulture).ToUpper(
                                              CultureInfo.InvariantCulture));
                configuration.SetProperty("hibernate.dialect", Dialect);
            }

            if ((options & ConfigurationFlags.Mappings) == ConfigurationFlags.Mappings)
            {
                foreach (Assembly assembly in MappingAssemblies)
                {
                    configuration.AddAssembly(assembly);
                }
            }

            if ((options & ConfigurationFlags.Interceptor) == ConfigurationFlags.Interceptor)
            {
                configuration.SetInterceptor(Interceptor);
            }

            return(configuration);
        }
Example #2
0
        public IDictionary <string, string> GetProperties()
        {
            if (Provider.IsEmpty())
            {
                throw new ApplicationException("DatabaseSettings unavailable. Make sure your application configuration file has appSetting entries for the necessary DatabaseSettings properties.");
            }
            var properties = new Dictionary <string, string>
            {
                { "connection.provider", Provider },
                { "connection.driver_class", Driver },
                { "dialect", Dialect },
                { "use_outer_join", UseOuterJoin.ToString().ToLowerInvariant() },
                { "connection.connection_string", ConnectionString },
                { "show_sql", ShowSql.ToString().ToLowerInvariant() },
                { "proxyfactory.factory_class", ProxyFactory }
            };

            if (IsCacheEnabled())
            {
                properties.Add("cache.provider_class", CacheProvider);
                properties.Add("cache.use_second_level_cache", "true");
                properties.Add("cache.use_query_cache", "true");
            }

            if (GenerateStatistics)
            {
                properties.Add("generate_statistics", "true");
            }


            return(properties);
        }
Example #3
0
        /// <summary>
        /// Converts this instance to key value pairs specifically for passing
        /// to NHibernate configuration.
        /// </summary>
        public IDictionary <string, string> GetAsNHiberateProperties()
        {
            var properties = new Dictionary <string, string>
            {
                { "connection.provider", Provider },
                { "connection.driver_class", DriverClass },
                { "dialect", Dialect },
                { "use_outer_join", UseOuterJoin.ToString() },
                { "connection.connection_string", ConnectionString },
                { "show_sql", ShowSql.ToString() },
                { "proxyfactory.factory_class", ProxyFactory }
            };

            return(properties);
        }