/// <summary> /// 拆分List /// </summary> /// <typeparam name="T"></typeparam> public class ListSplitter<T> { public static List<List<T>> SplitList(List<T> list, int chunkSize) { var result = new List<List<T>>(); for (int i = 0; i < list.Count; i += chunkSize) { result.Add(list.GetRange(i, Math.Min(chunkSize, list.Count - i))); } return result; } } //List拆分,每次5000條 int chunkSize = 5000; List<List<Rule>> splittedLists = ListSplitter<Rule>.SplitList(list, chunkSize); foreach (var splitList in splittedLists) { } |
|
來自: 修行的嘟嘟 > 《軟件開發(fā)》