/// <summary> /// 根据条件分页查询 /// 作者:HOTBOART 时间:2020/5/5 星期二 /// </summary> /// <param name="">分页对象</param> /// <param name="">查询条件</param> /// <returns>结果集</returns> public void GetPagingList(PageingModel <Goodstype> Paging, ICondition contion) { string Sql = "Select * FROM GoodsType" + " where " + contion.ToConditionString(); SqlParameter [] para = contion.ToParam().ToArray(); GetPaging(Paging, Sql, para); }
protected void GetPaging(PageingModel <T> Paging, string sql, params SqlParameter[] values) { string PagingSql = @"SELECT * FROM ( select ROW_NUMBER() over ( ORDER BY " + Paging.Order + ") AS NO ," + sql.Substring(sql.IndexOf(" ")) + " ) t WHERE t.no between " + ((Paging.PageIndex - 1) * Paging.PageSize + 1) + " and " + Paging.PageIndex * Paging.PageSize; string CalcCountSql = "SELECT Count(*) FROM (" + sql + ") T"; Paging.RecordCount = (int)getScalar(CalcCountSql, values); Paging.List = GetList(PagingSql, values); }