/// <summary> /// 创建 Dbs 实例 /// </summary> /// <param name="id"></param> /// <returns></returns> public static Dbs Create(int id) { Dbs dbs; lock (_dbses) { if (!_dbses.TryGetValue(id, out dbs)) { dbs = new Dbs(id, DbsKind.Unspecified); } } return(dbs); }
private void LoadFromCofiguration(Dbs dbs) { ConnectionStringSettings css = WebConfigurationManager.ConnectionStrings[dbs.QualifiedName] ?? ConfigurationManager.ConnectionStrings[dbs.QualifiedName]; if (css != null) { DbsProvider provider = DbsProvider.Providers.FirstOrDefault(a => string.Equals(a.Provider, css.ProviderName, StringComparison.CurrentCultureIgnoreCase) && a.Validate(css.ConnectionString)); DbsSetting setting = new DbsSetting(dbs, provider, css.ConnectionString) { Provider = provider }; Add(setting); } }
/// <summary> /// 返回一个克隆的实例。 /// </summary> /// <param name="source"></param> /// <param name="settings"></param> internal Dbs(Dbs source, ConnectionSettings settings) : this(source.Id, source.Kind, true) { _settings = settings; }
/// <summary> /// /// </summary> /// <param name="dbs"></param> /// <param name="provider"></param> public DbsSetting(Dbs dbs, DbsProvider provider) : this(dbs, provider, string.Empty) { }