/// <summary> /// Combines default/common connection information supplied in the "ConnectionStrings.UnicornStore" configuration, /// with override values supplied by the "UnicornDbConnectionStringBuilder" configuration settings section. /// </summary> /// <param name="di">DI container</param> /// <returns></returns> internal DbConnectionStringBuilder DbConnectionStringBuilderFactory <T>(IServiceProvider di, string defaultConnectionStringName) where T : DbConnectionStringBuilder, new() { DbConnectionStringBuilder overrideConnectionInfo = di.GetRequiredService <IOptionsSnapshot <T> >().Value; string defaultConnectionString = this.Configuration.GetConnectionString(defaultConnectionStringName); return(overrideConnectionInfo.MergeDbConnectionStringBuilders(defaultConnectionString)); }
internal static DbConnectionStringBuilder MergeDbConnectionStringBuilders(this DbConnectionStringBuilder overrideConnectionInfo, string defaultConnectionString) { var defaultConnectionStringBuilder = new DbConnectionStringBuilder { ConnectionString = defaultConnectionString }; overrideConnectionInfo.MergeDbConnectionStringBuilders(defaultConnectionStringBuilder); return(defaultConnectionStringBuilder); }