/// <summary> /// Mysql连接字符串构建 /// </summary> /// <param name="config"></param> /// <param name="serviceName"></param> /// <returns></returns> public static string BuildeMysqlConnectionString(this IConfiguration config, string serviceName = null) { MySqlServiceInfo info = string.IsNullOrEmpty(serviceName) ? config.GetSingletonServiceInfo <MySqlServiceInfo>() : config.GetRequiredServiceInfo <MySqlServiceInfo>(serviceName); MySqlProviderConnectorOptions mySqlConfig = new MySqlProviderConnectorOptions(config); MySqlProviderConnectorFactory factory = new MySqlProviderConnectorFactory(info, mySqlConfig, null); return(factory.CreateConnectionString()); }
private static string GetConnection(IConfiguration config, string serviceName = null) { var info = string.IsNullOrEmpty(serviceName) ? config.GetSingletonServiceInfo <MySqlServiceInfo>() : config.GetRequiredServiceInfo <MySqlServiceInfo>(serviceName); var mySqlConfig = new MySqlProviderConnectorOptions(config); var factory = new MySqlProviderConnectorFactory(info, mySqlConfig, null); return(factory.CreateConnectionString()); }
private IEnumerable <IHealthContributor> GetHealthContributors() { var info = ApplicationConfig.Configuration.GetSingletonServiceInfo <MySqlServiceInfo>(); var mySqlConfig = new MySqlProviderConnectorOptions(ApplicationConfig.Configuration); var factory = new MySqlProviderConnectorFactory(info, mySqlConfig, MySqlTypeLocator.MySqlConnection); var healthContributors = new List <IHealthContributor> { new DiskSpaceContributor(), new RelationalHealthContributor(new MySqlConnection(factory.CreateConnectionString())) }; return(healthContributors); }
private static string GetConnection(IConfiguration config, string serviceName = null) { MySqlServiceInfo info = null; if (string.IsNullOrEmpty(serviceName)) { info = config.GetSingletonServiceInfo <MySqlServiceInfo>(); } else { info = config.GetRequiredServiceInfo <MySqlServiceInfo>(serviceName); } MySqlProviderConnectorOptions mySqlConfig = new MySqlProviderConnectorOptions(config); MySqlProviderConnectorFactory factory = new MySqlProviderConnectorFactory(info, mySqlConfig); return(factory.CreateConnectionString()); }