AzurePoolCrossDbGenerator/DbAccess.cs
/// <summary>
/// Get a connection string for the matching DB or log an error.
/// </summary>
/// <param name="config"></param>
/// <param name="dbName"></param>
/// <returns></returns>
Get a connection string for the matching DB or log an error.
Get a connection string for the matching DB or log an error .
public static string GetConnectionString(Configs.InitialConfig config, string dbName)
        {
            string regexPattern = $".*Initial Catalog={dbName};.*";
            var regexOptions = RegexOptions.Multiline | RegexOptions.IgnoreCase;
            string cs = Regex.Match(config.connections, regexPattern, regexOptions)?.Value;
            if (string.IsNullOrEmpty(cs))
            {
                cs = "connection_string_required"; 
                Program.WriteLine($"{config.mirrorDB} / {dbName}: missing connection string.", ConsoleColor.Red);
                Program.ExitApp();
            }
            return cs;
        }
public static string GetConnectionString ( Configs . InitialConfig config , string dbName ) { string regexPattern = $" .*Initial Catalog= { dbName } ;.* " ; var regexOptions = RegexOptions . Multiline | RegexOptions . IgnoreCase ; string cs = Regex . Match ( config . connections , regexPattern , regexOptions ) ? . Value ; if ( string . IsNullOrEmpty ( cs ) ) { cs = " " ; Program . WriteLine ( $" { config . mirrorDB }  /  { dbName } : missing connection string. " , ConsoleColor . Red ) ; Program . ExitApp ( ) ; } return cs ; }
Get a connection string for the matching DB or log an error.
Get a connection string for the matching DB or log an error .
// a placeholder in case the CS is missing
None
config
Configs.InitialConfig
None
dbName
string
None