Exemplo n.º 1
0
        public static void BatchTest()
        {
            Level1 level1 = new Level1();

            level1.Value  = "test";
            level1.Id     = levelIds[0]++;
            level1.levels = new List <Level2>();
            long ms = 0;

            using (new MetricTracker("Simple save test", t => ms = t))
            {
                for (int i = 0; i < 1296; i++)
                {
                    Level2 curLevel2 = new Level2();
                    level1.levels.Add(curLevel2);
                    curLevel2.Id     = levelIds[1]++;
                    curLevel2.Value  = "test" + i.ToString();
                    curLevel2.levels = new List <Level3>();
                }
                using (Levels context = new Levels())
                {
                    context.Level1.Add(level1);
                    context.SaveChanges();
                }
            }

            using (new MetricTracker("Complex save test - preparation ", t => ms = t))
            {
                level1 = GetSample();
            }

            using (Levels context = new Levels())
                using (new MetricTracker("Complex save test - Save", t => ms = t))
                {
                    context.Level1.Add(level1);
                    context.SaveChanges();
                }
        }