/// <summary> /// 获取实体对应的数据表 /// </summary> /// <param name="dataBaseName">数据库名称</param> /// <param name="selectObjet">查询对象</param> /// <param name="selectWhere">查询条件</param> /// <returns></returns> public static DataTable GetDataTable(string dataBaseName, string selectObjet, params string[] selectWhere) { DataBaseInfo _database = DataBaseConfig.Instance.GetDataBaseInfoByCache(dataBaseName); return(GetDataTable(_database, selectObjet, selectWhere)); }
/// <summary> /// 根据提供的查询条件,返回实体列表 /// </summary> /// <typeparam name="T">实体类型</typeparam> /// <param name="selectDataBaseName">查询数据库名称</param> /// <param name="selectObjet">查询对象</param> /// <param name="selectWhere">查询条件(需要带上 AND)</param> /// <returns></returns> public static List <T> GetEntityList <T>(string selectDataBaseName, string selectObjet, params string[] selectWhere) { DataBaseInfo _database = DataBaseConfig.Instance.GetDataBaseInfoByCache(selectDataBaseName); return(GetEntityList <T>(_database, selectObjet, selectWhere)); }
/// <summary> /// 根据提供的查询条件,放回实体列表 /// </summary> /// <typeparam name="T">实体类型</typeparam> /// <param name="selectDatabase">查询数据库</param> /// <param name="selectObjet">查询对象</param> /// <param name="selectWhere">查询条件</param> /// <returns></returns> public static List <T> GetEntityList <T>(DataBaseInfo selectDatabase, string selectObjet, params string[] selectWhere) { return(GetEntityList <T>(GetDataTable(selectDatabase, selectObjet, selectWhere))); }
/// <summary> /// 加载配置文件信息 /// </summary> /// <param name="node"></param> public override void Load(System.Xml.XmlElement node) { base.Load(node); foreach (XmlNode item in node.SelectSingleNode("ConnString")) { #region 链接字符串表示的数据库信息 //数据库名称 string _name = item.Name; //连接字符串 string _connStr = item.InnerText; if (item.Attributes["IfEncrypt"] != null) { if (item.Attributes["IfEncrypt"].Value == "true") { _connStr = Components.TextHelper.AESDecrypt(_connStr); } } else { _connStr = Components.TextHelper.AESDecrypt(_connStr); } //连接类型 DataBaseType _type = DataBaseType.Sql; if (item.Attributes["Type"] != null) { switch (item.Attributes["Type"].Value) { case "Sql": _type = DataBaseType.Sql; break; case "Oracle": _type = DataBaseType.Oracle; break; case "MySql": _type = DataBaseType.MySql; break; case "Db": _type = DataBaseType.Db; break; case "Access": _type = DataBaseType.Access; break; default: _type = DataBaseType.Sql; break; } } if (string.IsNullOrEmpty(_connStr)) { continue; } DataBaseInfo _info = new DataBaseInfo(_name, _connStr, _type); if (m_dataBaseList.ContainsKey(_name)) { throw new Exception("数据库配置[" + Name + "]已经添加了相同的数据库信息[" + _name + "]"); } else { m_dataBaseList.Add(_name, _info); } #endregion } }