zoukankan      html  css  js  c++  java
  • 数据分页的另一种写法

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;

    namespace ConsoleApplication7
    {
    class Program
    {
    static void Main(string[] args)
    {
    List<int> deletedList=new List<int>();
    for (int i = 0; i < 1785; i++)
    {
    deletedList.Add(i);
    }
    string tempSql = "delete from ccr where id in (";
    int pageSize = 3;
    int tempIdsCount = 0;
    int totalCount = deletedList.Count;
    int pageCount = (totalCount - 1) / pageSize + 1;
    int currentPageIndex = 1;
    //删除采用分批次去删除防止超时
    for (var i = 0; i < deletedList.Count; i++)
    {
    tempSql += deletedList[i] + ",";
    tempIdsCount++;
    if (currentPageIndex < pageCount)
    {
    if (tempIdsCount >= pageSize)
    {
    tempSql =tempSql.TrimEnd(',') + ")";
    try
    {
    Console.WriteLine("第"+currentPageIndex+"页 :");
    Console.WriteLine(tempSql);
    }
    catch (Exception ex)
    {
    //JSUtil.log(ex.Message);
    }
    tempIdsCount = 0;
    tempSql = "delete from RiskBookSelection where Id in (";
    currentPageIndex++;
    }
    }
    else
    {
    tempSql = "delete from RiskBookSelection where Id in (";
    int skip = totalCount - (pageCount - 1) * pageSize;
    int ii = i;
    for (var j = ii; j <= ii + skip - 1; j++)
    {
    tempSql += deletedList[j] + ",";
    }
    tempSql =tempSql.TrimEnd(',') + ")";

    //这里可能由于我的计算误差有两个未删除这里独立再删除一次 修改者kexb
    Console.WriteLine("最后一页 ");
    Console.WriteLine(tempSql);


    break;
    }


    }
    Console.ReadKey();
    }
    }
    }

  • 相关阅读:
    笔试小题
    java泛型
    HTML 字符实体 &lt; &gt: &amp;等
    HttpClient Get/Post方式调用Http接口
    Webservice简介
    Mybtis框架总结(一)
    java 获取当月第一天和最后一天 获取前一个月第一天和最后一天
    java程序员需要掌握些什么知识
    Float和double丢失精度问题及解决方案
    ViewController的viewWillLayoutSubviews作用
  • 原文地址:https://www.cnblogs.com/kexb/p/4710178.html
Copyright © 2011-2022 走看看