private static void InitData(AdoHelper db, System.Diagnostics.Stopwatch watch) { //自动创建数据库和表 LocalDbContext context = new LocalDbContext(); Console.WriteLine("需要初始化数据吗?(Y/N) "); string input = Console.ReadLine(); if (input.ToLower() != "y") { return; } Console.WriteLine("正在初始化数据,请稍后。。。。"); context.TruncateTable <User>(); Console.WriteLine("..."); watch.Restart(); List <User> batchList = new List <User>(); for (int i = 0; i < 100000; i++) { User zhang_yeye = new User() { ID = 1000 + i, Name = "zhang yeye" + i, Pwd = "pwd" + i, RegistedDate = DateTime.Now }; //count += EntityQuery<User>.Instance.Insert(zhang_yeye);//采用泛型 EntityQuery 方式插入数据 batchList.Add(zhang_yeye); } watch.Stop(); Console.WriteLine("准备数据 耗时:(ms)" + watch.ElapsedMilliseconds); watch.Restart(); int count = EntityQuery <User> .Instance.QuickInsert(batchList); watch.Stop(); Console.WriteLine("QuickInsert List (100000 item) 耗时:(ms)" + watch.ElapsedMilliseconds); System.Threading.Thread.Sleep(1000); }