/// <summary> /// 执行分页查询 按类别编号 关键字查询 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="typeId"></param> /// <param name="keywords"></param> /// <param name="strCols"></param> /// <param name="proName"></param> /// <param name="startIndex"></param> /// <param name="pageSize"></param> /// <returns></returns> public DataSet GetPageDs <S>(string strWhere, int typeId, string keywords, string strCols, string proName, int startIndex, int pageSize) { List <SqlParameter> listParas = new List <SqlParameter>(); listParas.Add(new SqlParameter("@typeId", typeId)); listParas.Add(new SqlParameter("@keywords", keywords)); string sql = CreateSql.CreateRowsSelectSql <S>(strWhere, strCols); listParas.Add(new SqlParameter("@sql", sql)); listParas.Add(new SqlParameter("@startIndex", startIndex)); listParas.Add(new SqlParameter("@endIndex", startIndex + pageSize - 1)); DataSet ds = GetDs(proName, 2, listParas.ToArray()); return(ds); }
/// <summary> /// 返回带行序号的列表 /// </summary> /// <param name="strWhere"></param> /// <param name="strCols"></param> /// <param name="paras"></param> /// <returns></returns> public List <T> GetRowsModelList(string strWhere, string strCols, params SqlParameter[] paras) { if (string.IsNullOrEmpty(strWhere)) { strWhere = "1=1"; } //生成查询语句 string selSql = CreateSql.CreateRowsSelectSql <T>(strWhere, strCols); //生成Reader SqlDataReader reader = SqlHelper.ExecuteReader(selSql, 1, paras); //转换为List<T>列表 List <T> list = DbConvert.SqlDataReaderToList <T>(reader, strCols + ",Id"); //关闭阅读器 reader.Close(); return(list); }