Exemple #1
0
        /// <summary>
        ///  根据实体属性查询条件,返回实体列表
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <returns></returns>
        public static List <T> GetEntityList <T>()
        {
            Type _entityType = typeof(T);

            //获取数据库查询配置属性
            object[] _tempAttr = _entityType.GetCustomAttributes(typeof(DataEntitySelectAttribute), false);
            if (_tempAttr.Length == 0)
            {
                throw new Exception("没有配置实体属性,无法获取实体信息");
            }
            DataEntitySelectAttribute _entityAttribute = _tempAttr[0] as DataEntitySelectAttribute;

            //根据查询信息返回对象
            return(GetEntityList <T>(_entityAttribute.SelectDatabase, _entityAttribute.SelectObject, _entityAttribute.SelectWhere));
        }
Exemple #2
0
 /// <summary>
 /// 根据实体数据查询属性获取数据表
 /// </summary>
 /// <param name="attribute"></param>
 /// <returns></returns>
 public static DataTable GetDataTable(DataEntitySelectAttribute attribute)
 {
     return(GetDataTable(attribute.SelectDatabase, attribute.SelectObject, attribute.SelectWhere));
 }