List中 GetRange (int index, int count)的使用


GetRange:在源 List<T> 中创建元素范围的浅表复制。

            int u = 0;
            while (u != -1)
            {
                List<T> uplist = new List<T>();
                u++;
                
                if (u * 500 <= updateList.Count)
                {
                    uplist = updateList.GetRange((u - 1) * 500, 500);
                }
                else
                {
                    uplist = updateList.GetRange((u - 1) * 500, updateList.Count - (u - 1) * 500);
                    u = -1;
                }
                if (!r.Update(uplist))
                {
                    msg += "更新:" + r.GetAlertMessage();
                }
            }

这里场景是由于限制了sql执行超时时间,数据量过大对数据库进行操作时会出现超时
这里分为每500条数据进行一次插入

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM