/// <summary> /// Postgre连接字符串构建 /// </summary> /// <param name="config"></param> /// <param name="serviceName"></param> /// <returns></returns> public static string BuildePostgreConnectionString(this IConfiguration config, string serviceName = null) { PostgresServiceInfo info = string.IsNullOrEmpty(serviceName) ? config.GetSingletonServiceInfo <PostgresServiceInfo>() : config.GetRequiredServiceInfo <PostgresServiceInfo>(serviceName); PostgresProviderConnectorOptions mySqlConfig = new PostgresProviderConnectorOptions(config); PostgresProviderConnectorFactory factory = new PostgresProviderConnectorFactory(info, mySqlConfig, null); return(factory.CreateConnectionString()); }
private static string GetConnection(IConfiguration config, string serviceName = null) { var info = string.IsNullOrEmpty(serviceName) ? config.GetSingletonServiceInfo <PostgresServiceInfo>() : config.GetRequiredServiceInfo <PostgresServiceInfo>(serviceName); var postgresConfig = new PostgresProviderConnectorOptions(config); var factory = new PostgresProviderConnectorFactory(info, postgresConfig, null); return(factory.CreateConnectionString()); }