internal static IDataProvider?ProviderDetector(IConnectionStringSettings css, string connectionString) { switch (css.ProviderName) { case ProviderName.PostgreSQL92: return(_postgreSQLDataProvider92.Value); case ProviderName.PostgreSQL93: return(_postgreSQLDataProvider93.Value); case ProviderName.PostgreSQL95: return(_postgreSQLDataProvider95.Value); case "": case null: if (css.Name == "PostgreSQL") { goto case "Npgsql"; } break; case NpgsqlProviderAdapter.ClientNamespace: case var providerName when providerName.Contains("PostgreSQL") || providerName.Contains(NpgsqlProviderAdapter.AssemblyName): if (css.Name.Contains("92") || css.Name.Contains("9.2")) return(_postgreSQLDataProvider92.Value); if (css.Name.Contains("93") || css.Name.Contains("9.3") || css.Name.Contains("94") || css.Name.Contains("9.4")) return(_postgreSQLDataProvider93.Value); if (css.Name.Contains("95") || css.Name.Contains("9.5") || css.Name.Contains("96") || css.Name.Contains("9.6")) return(_postgreSQLDataProvider95.Value); if (AutoDetectProvider) { try { var cs = string.IsNullOrWhiteSpace(connectionString) ? css.ConnectionString : connectionString; using (var conn = NpgsqlProviderAdapter.GetInstance().CreateConnection(cs)) { conn.Open(); var postgreSqlVersion = conn.PostgreSqlVersion; if (postgreSqlVersion.Major > 9 || postgreSqlVersion.Major == 9 && postgreSqlVersion.Minor > 4) { return(_postgreSQLDataProvider95.Value); } if (postgreSqlVersion.Major == 9 && postgreSqlVersion.Minor > 2) { return(_postgreSQLDataProvider93.Value); } return(_postgreSQLDataProvider92.Value); } } catch { return(_postgreSQLDataProvider92.Value); } } return(GetDataProvider()); } return(null); }
public PostgreSQL95MappingSchema() : base(ProviderName.PostgreSQL95, NpgsqlProviderAdapter.GetInstance().MappingSchema, Instance) { }