private IDb GetDbByEntityFullName(string entityFullName) { IDb reval = null; if (string.IsNullOrEmpty(entityFullName)) { return(reval); } var list = DbMapping.GetZeroDbConfigDatabaseInfoByEntityFullName(entityFullName); if (list == null || list.Count < 1) { return(reval); } var info = list[0]; if (!_dbInstanceDic.ContainsKey(info.dbKey)) { lock (_lock) { #region -- code -- if (!_dbInstanceDic.ContainsKey(info.dbKey)) { IDb db = DbFactory.Create(info, _dbExecuteSqlEvent); if (db != null) { _dbInstanceDic.Add(info.dbKey, db); reval = db; } } else { reval = _dbInstanceDic[info.dbKey]; } #endregion } } else { reval = _dbInstanceDic[info.dbKey]; } return(reval); }
public IDb GetDbByDbKey(string dbKey) { IDb reval = null; var info = DbMapping.GetZeroDbConfigDatabaseInfo(dbKey); if (info == null) { return(null); } if (!_dbInstanceDic.ContainsKey(info.dbKey)) { lock (_lock) { #region -- code -- if (!_dbInstanceDic.ContainsKey(info.dbKey)) { IDb db = DbFactory.Create(info, _dbExecuteSqlEvent); if (db != null) { _dbInstanceDic.Add(info.dbKey, db); reval = db; } } else { reval = _dbInstanceDic[info.dbKey]; } #endregion } } else { reval = _dbInstanceDic[info.dbKey]; } return(reval); }