protected BaseProviderDb(string connectionStringAppKeyName) { this._dbAccess = new Lazy<IDbAccess>(() => { var access = new MsSqlDbAccess((p) => DbProviderFactories.GetFactory(p), new QueryProfile()); var old = access.Information.ConnectionString; access.Information.ConnectionString = () => { string connStr; return ProviderConnectionStrings.TryGetValue(connectionStringAppKeyName, out connStr) ? connStr : old(); }; return access; }); }
protected BaseProviderDb(string connectionStringAppKeyName) { this._dbAccess = new Lazy<IDbAccess>(() => { var access = new MsSqlDbAccess((p) => DbProviderFactories.GetFactory(p), new QueryProfile()); var old = access.Information.ConnectionString; access.Information.ConnectionString = () => { if (YafContext.Application[connectionStringAppKeyName] != null) { return YafContext.Application[connectionStringAppKeyName] as string; } return old(); }; return access; }); }