public PostgresVersionInfo(ConnectionInfo connectionInfo) { Contract.Requires(connectionInfo != null); Contract.Requires(connectionInfo.ConnectionString != null); using (var connection = connectionInfo.GetConnection()) { connection.Open(); var version = connection.PostgreSqlVersion; Major = version.Major; Minor = version.Minor; connection.Close(); } }
public PostgresConnectionPool(ConnectionInfo info, ILogFactory logFactory) { this.Info = info; if (!int.TryParse(ConfigurationManager.AppSettings["Database.PoolSize"], out Size)) Size = 20; if (!Enum.TryParse<PoolMode>(ConfigurationManager.AppSettings["Database.PoolMode"], out Mode)) Mode = PoolMode.IfAvailable; if (Mode != PoolMode.None) { if (Size < 1) Size = 1; for (int i = 0; i < Size; i++) Connections.Add(info.GetConnection()); } this.Logger = logFactory.Create("Npgsql connection manager"); }
public PostgresConnectionPool(ConnectionInfo info) { this.Info = info; if (!int.TryParse(ConfigurationManager.AppSettings["Database.PoolSize"], out Size)) Size = Math.Min(Environment.ProcessorCount, 20); if (!Enum.TryParse<PoolMode>(ConfigurationManager.AppSettings["Database.PoolMode"], out Mode)) { //TODO: Mono has issues with BlockingCollection. use None as default int p = (int)Environment.OSVersion.Platform; if (p == 4 || p == 6 || p == 128) Mode = PoolMode.None; else Mode = PoolMode.IfAvailable; } if (Mode != PoolMode.None) { if (Size < 1) Size = 1; for (int i = 0; i < Size; i++) Connections.Add(info.GetConnection()); } }
public PostgresConnectionPool(ConnectionInfo info) { this.Info = info; #if !NETSTANDARD2_0 if (!int.TryParse(ConfigurationManager.AppSettings["Database.PoolSize"], out Size)) #endif Size = Math.Min(Environment.ProcessorCount, 20); #if NETSTANDARD2_0 if (true) #else if (!Enum.TryParse <PoolMode>(ConfigurationManager.AppSettings["Database.PoolMode"], out Mode)) #endif { //TODO: Mono has issues with BlockingCollection. use None as default int p = (int)Environment.OSVersion.Platform; if (p == 4 || p == 6 || p == 128) { Mode = PoolMode.None; } else { Mode = PoolMode.IfAvailable; } } if (Mode != PoolMode.None) { if (Size < 1) { Size = 1; } for (int i = 0; i < Size; i++) { Connections.Add(info.GetConnection()); } } }