public static DbDataReader Paging(this DbOperator op, string sql, string sequence, int pageIndex, int pageSize, out int rowCount, bool doCount) { if (string.IsNullOrEmpty(sql)) { throw new ArgumentNullException("sql"); } if (pageIndex < 1) { throw new ArgumentOutOfRangeException("pageIndex"); } if (pageSize < 1) { throw new ArgumentOutOfRangeException("pageSize"); } int start = (pageIndex - 1) * pageSize + 1; int end = pageIndex * pageSize; rowCount = 0; sql = sql.Trim().TrimEnd(';'); if (doCount) { rowCount = Counting(op, sql); } string paging = string.Format("select t2.* from (SELECT *, ROW_NUMBER() OVER(order by {1}) as rowNum from ({0}) as t) t2 where t2.rowNum>={2} and t2.rowNum<={3}", sql, sequence, start, end); return(op.ExecuteReader(paging)); }
private static DbDataReader Readers(DbOperator dbOperator, string sql) { if (string.IsNullOrEmpty(sql)) { throw new ArgumentNullException("sql"); } return(dbOperator.ExecuteReader(sql)); }
public static DbDataReader Paging(this DbOperator op, string sql, int pageIndex, int pageSize, out int rowCount, bool doCount) { if (string.IsNullOrEmpty(sql)) { throw new ArgumentNullException("sql"); } rowCount = Counting(op, sql); return(op.ExecuteReader(sql)); }
private static DbDataReader Pagings(DbOperator dbOperator, string sql, string sequence, int pageIndex, int pageSize, out int rowCount) { if (string.IsNullOrEmpty(sql)) { throw new ArgumentNullException("sql"); } if (pageIndex < 1) { throw new ArgumentOutOfRangeException("pageIndex"); } if (pageSize < 1) { throw new ArgumentOutOfRangeException("pageSize"); } int start = (pageIndex - 1) * pageSize + 1; int end = pageIndex * pageSize; rowCount = Counting(dbOperator, sql); string paging = string.Format("select t2.* from (SELECT ROW_NUMBER() OVER(order by {1}) as rowNum,* from ({0}) as t) t2 where t2.rowNum>{2} and t2.rowNum<={3}", sql, sequence, start, end); return(dbOperator.ExecuteReader(paging)); }