public static SessionFactoryConfig Set(this SessionFactoryConfig config, IDictionary <string, string> properties) { foreach (var property in properties) { config.Set(property.Key, property.Value); } return(config); }
/// <summary> /// Sets the default configuration for database specifiend by <paramref name="name"/>. /// </summary> /// <param name="config"></param> /// <param name="name">Name of the database type.</param> /// <param name="connectionStringName">name of the connection string specified in connectionStrings configuration section</param> /// <returns></returns> protected void SetDefaults(SessionFactoryConfig config, string name, string connectionStringName) { var names = Enum.GetNames(typeof(DatabaseType)); if (!Array.Exists(names, n => n.Equals(name, StringComparison.OrdinalIgnoreCase))) { var builder = new StringBuilder(); builder.AppendFormat("Specified value ({0}) is not valid for 'database' attribute. Valid values are:", name); foreach (var value in Enum.GetValues(typeof(DatabaseType))) { builder.AppendFormat(" '{0}'", value.ToString()); } builder.Append("."); throw new ConfigurationErrorsException(builder.ToString()); } var type = (DatabaseType)Enum.Parse(typeof(DatabaseType), name, true); config.Set(NHibernate.Cfg.Environment.ConnectionStringName, connectionStringName) .SetDatabaseType(type); }
public static SessionFactoryConfig ConnectionDriver <T>(this SessionFactoryConfig config) where T : IDriver { return(config.Set(Environment.ConnectionDriver, LongName <T>())); }
public static SessionFactoryConfig Dialect <T>(this SessionFactoryConfig config) where T : Dialect { return(config.Set(Environment.Dialect, LongName <T>())); }
public static SessionFactoryConfig CommandTimeout(this SessionFactoryConfig config, int timeout) { return(config.Set(Environment.CommandTimeout, timeout.ToString(CultureInfo.InvariantCulture))); }
public static SessionFactoryConfig ConnectionString(this SessionFactoryConfig config, string connectionstring) { return(config.Set(Environment.ConnectionString, connectionstring)); }
public static SessionFactoryConfig UseQueryCache(this SessionFactoryConfig config, bool usequerycache) { return(config.Set(Environment.UseQueryCache, usequerycache.ToString(CultureInfo.InvariantCulture))); }
public static SessionFactoryConfig UseSecondLevelCache(this SessionFactoryConfig config, bool cache) { return(config.Set(Environment.UseSecondLevelCache, cache.ToString(CultureInfo.InvariantCulture))); }
public static SessionFactoryConfig QuerySubstitutions(this SessionFactoryConfig config, string substitutions) { return(config.Set(Environment.QuerySubstitutions, substitutions)); }
public static SessionFactoryConfig CacheProvider <T>(this SessionFactoryConfig config) where T : ICacheProvider { return(config.Set(Environment.CacheProvider, LongName <T>())); }
public static SessionFactoryConfig CacheDefaultExpiration(this SessionFactoryConfig config, int expiration) { return(config.Set(Environment.CacheDefaultExpiration, expiration.ToString(CultureInfo.InvariantCulture))); }
public static SessionFactoryConfig ShowSql(this SessionFactoryConfig config, bool showsql) { return(config.Set(Environment.ShowSql, showsql.ToString(CultureInfo.InvariantCulture))); }
public static SessionFactoryConfig Isolation(this SessionFactoryConfig config, IsolationLevel isolation) { return(config.Set(Environment.Isolation, isolation.ToString())); }
public static SessionFactoryConfig BatchSize(this SessionFactoryConfig config, int batchsize) { return(config.Set(Environment.BatchSize, batchsize.ToString(CultureInfo.InvariantCulture))); }
public static SessionFactoryConfig ProxyFactoryFactoryClass <T>(this SessionFactoryConfig config) where T : IProxyFactoryFactory { return(config.Set(Environment.ProxyFactoryFactoryClass, LongName <T>())); }
public static SessionFactoryConfig MaxFetchDepth(this SessionFactoryConfig config, int depth) { return(config.Set(Environment.MaxFetchDepth, Math.Min(3, depth).ToString(CultureInfo.InvariantCulture))); }
/// <summary> /// Sets the default configuration for database specifiend by <paramref name="name"/>. /// </summary> /// <param name="config"></param> /// <param name="name">Name of the database type.</param> /// <param name="connectionStringName">name of the connection string specified in connectionStrings configuration section</param> /// <returns></returns> protected void SetDefaults(SessionFactoryConfig config, string name, string connectionStringName) { var names = Enum.GetNames(typeof(DatabaseType)); if (!Array.Exists(names, n => n.Equals(name, StringComparison.OrdinalIgnoreCase))) { var builder = new StringBuilder(); builder.AppendFormat("Specified value ({0}) is not valid for 'database' attribute. Valid values are:", name); foreach (var value in Enum.GetValues(typeof(DatabaseType))) { builder.AppendFormat(" '{0}'", value.ToString()); } builder.Append("."); throw new ConfigurationErrorsException(builder.ToString()); } var type = (DatabaseType)Enum.Parse(typeof(DatabaseType), name, true); config.Set(NHibernate.Cfg.Environment.ConnectionStringName, connectionStringName) .SetDatabaseType(type); }
public static SessionFactoryConfig CacheRegion(this SessionFactoryConfig config, string region) { return(config.Set(Environment.CacheRegionPrefix, region)); }