public static SqlConnection OpenSqlConnection( this ISqlServerLocator sqlLocator, TimeSpan connectionTimeout) { sqlLocator.MustForArg(nameof(sqlLocator)).NotBeNull(); var connectionString = sqlLocator.BuildConnectionString(connectionTimeout); var result = connectionString.OpenSqlConnection(); return(result); }
/// <summary> /// Builds the connection string. /// </summary> /// <param name="sqlLocator">The SQL locator.</param> /// <param name="connectionTimeout">Timeout for the connection.</param> /// <returns>SQL Connection string.</returns> public static string BuildConnectionString( this ISqlServerLocator sqlLocator, TimeSpan connectionTimeout) { sqlLocator.MustForArg(nameof(sqlLocator)).NotBeNull(); var connectionString = ConnectionStringHelper.BuildConnectionString( sqlLocator.ServerName, sqlLocator.Port, sqlLocator.InstanceName, sqlLocator.DatabaseName, sqlLocator.UserName, sqlLocator.Password, (int)connectionTimeout.TotalSeconds); return(connectionString); }