示例#1
0
        /// <summary>
        /// 分页查询,基础方法,参数:页面大小,页码,主键,查询字段,表达式,排序,数据总条数
        /// </summary>
        /// <param name="pageSize">页面大小</param>
        /// <param name="pageIndex">页码</param>
        /// <param name="primaryKey">主键</param>
        /// <param name="selectFields">查询字段</param>
        /// <param name="express">表达式</param>
        /// <param name="orderBy">排序</param>
        /// <param name="recordCount">数据总条数</param>
        /// <returns></returns>
        private List <TEntity> Search(int pageSize, int pageIndex, string primaryKey, string selectFields, List <Expression> express, string orderBy, ref int recordCount)
        {
            //获取参数和条件
            CoreFrameworkEntity CoreFrameworkEntity = GetParaListAndWhere(express);

            //条件
            string where = CoreFrameworkEntity.where;
            //参数列表
            List <SqlParameter> listPara = CoreFrameworkEntity.paraList;

            selectFields = selectFields == "" ? "*" : selectFields;//查询字段

            Pager       page = new Pager();
            IDataReader sdr  = page.GetPagerInfo(tableName, primaryKey, selectFields, pageSize, pageIndex, where, orderBy, ref recordCount, listPara);

            return(DynamicBuilder <TEntity> .GetList(sdr, columnAttrList));
        }
示例#2
0
        /// <summary>
        /// 不分页查询,基础方法
        /// </summary>
        /// <param name="count">显示总数,空则全部显示</param>
        /// <param name="selectFields">查询字段</param>
        /// <param name="express">表达式</param>
        /// <param name="orderBy">排序,为空则不排序</param>
        /// <returns></returns>
        private List <TEntity> Search(int?count, string selectFields, List <Expression> express, string orderBy)
        {
            //获取参数和条件
            CoreFrameworkEntity CoreFrameworkEntity = GetParaListAndWhere(express);

            //条件
            string where = CoreFrameworkEntity.where;
            //参数列表
            List <SqlParameter> listPara = CoreFrameworkEntity.paraList;

            selectFields = selectFields == "" ? "*" : selectFields;    //查询字段
            orderBy      = orderBy == "" ? "" : "order by " + orderBy; //排序

            string      topStr  = count.HasValue == false ? "" : " top " + count + " ";
            string      cmdText = "select " + topStr + selectFields + " from " + tableName + " where " + where + " " + orderBy;
            IDataReader sdr     = new SqlConvertHelper().ExecuteReader(cmdText, listPara);

            return(DynamicBuilder <TEntity> .GetList(sdr, columnAttrList));
        }