您的位置:首页 > 数据库

(工作笔记)数据分批次操作,封装方法(sql添删改查)

2017-10-25 17:13 288 查看
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_36333371/article/details/78343778
//
// idList为数据总的和,count代表按照多少一组
//
public static IList<IList<int>> GetlistGroup(IList<int> idList,int count)
{
IList<int> templist = null;
IList<IList<int>> relist = new List<IList<int>>();
for (int i = 0; i < (idList.Count % count == 0 ? idList.Count / count : idList.Count / count + 1); i++)
{
templist = new List<int>();
for (int j = 0; j < count; j++)
{
int index = i * count + j;
if (index == idList.Count) { break; }
templist.Add(idList[index]);
}
relist.Add(templist);
}
return relist;

}

//调用
IList<IList<int>> relist = GetlistGroup(list,100);
string ids = string.Empty;
for (int i = 0; i < relist.Count; i++)
{
 ids =string.Join(",", relist[i].ToArray());
         string strSQL = string.Format("update {0} set synstatus = 1 where {1} in ({2})", tableName, idName, ids);

}



          





阅读更多
                                            
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐