Exemplo n.º 1
0
        public ActionResult AddEF()
        {
            List <Test> listModel = new List <Test>();
            int         count     = 10000;

            for (int i = 0; i < count; i++)
            {
                Model.Entities.Test model = new Test();

                model.id  = Guid.NewGuid().ToString();
                model.id1 = i.ToString();
                model.id2 = "我不是大牛";
                model.id3 = "我从4月30日开始写这个系列到今天(5月20日已经全家人的支持表示感谢";
                model.id4 = "时间不等人";
                model.id5 = "呵呵哒";
                listModel.Add(model);
            }
            Stopwatch sw = new Stopwatch();

            sw.Start();
            testService.AddAllEntity(listModel);
            sw.Stop();
            var    temp = sw.Elapsed;
            string date = "1W数据  使用EF的批量插入总耗时为:" + temp.ToString();

            return(Content(date));
        }