/// <summary> /// Add a new connection to the configuration context. /// </summary> /// <param name="connectionName"></param> /// <param name="connectionString"></param> /// <param name="providerName"></param> public static void AddConnectionString(String connectionName, String connectionString, String providerName = null) { ConnectionStrings.AddOrUpdate(connectionName, connectionString, (name, old) => connectionString); if (providerName != null) { var factory = DatabaseConfigurationContext.GetProviderFactory(providerName); DbProviders.AddOrUpdate(connectionName, factory, (name, oldFactory) => factory); } }
public static ISqlDialectVariant GetSqlDialect(String connectionName) { var provider = DatabaseConfigurationContext.GetProviderForConnection(connectionName); if (provider is Npgsql.NpgsqlFactory) { return(ReflectionHelper.GetNewObject <PostgresSqlDialectVariant>()); } else { return(ReflectionHelper.GetNewObject <SqlServerSqlDialectVariant>()); } }
public static void AddParametersToCommand(dynamic procedureParams, DbCommand cmd, String connectionName = null) { DbProviderFactory provider = DatabaseConfigurationContext.GetProviderForConnection(connectionName); AddParametersToCommandFromProvider(procedureParams, cmd, provider); }
public static void AddParameterToCommand(String name, Object value, DbCommand cmd, String connectionName = null, DbType?dbType = null) { DbProviderFactory provider = DatabaseConfigurationContext.GetProviderForConnection(connectionName); AddParameterToCommand(name, value, cmd, provider: provider); }