var pageList = new Dictionary<int, int>();//分批次查询
var pageSize = 10000;//每次返回1w条
float total = 总条数;
var arr = (total / pageSize).ToString().Split('.');
var totalPage = int.Parse(arr[0]) + (arr.Length == 2 ? 1 : 0);//有小数则+1
for (int currNo = 1; currNo <= totalPage; currNo++)
{
int startNum = 1 + (pageSize * (currNo - 1));//起
int endNum = pageSize * currNo; //止
pageList.Add(startNum, endNum);
}
var dt = new DataTable();
//分批次查询
foreach (var item in pageList)
{
var tempSql = $" select * from (select rownum rn ,tbl.* from tbl ) where rn between {item.Key} and {item.Value}"; //分页查询
var tempDt = GetTable(tempSql);
if (tempDt != null && tempDt.Rows.Count > 0)
{
dt.Merge(tempDt);
}
}