コード例 #1
0
ファイル: Program.cs プロジェクト: evertonmota/SamuraiAppCore
        private static void InsertMultipleSamurais()
        {
            var samurai = new Samurai {
                Name = "MR. M"
            };
            var battle = new Battle
            {
                Name      = "Senhor dos Aneis",
                StartDate = new DateTime(1800, 05, 25),
                EndDate   = new DateTime(1900, 05, 01)
            };

            using (var context = new SamuraiDbContext())
            {
                context.AddRange(samurai, battle);
                context.SaveChanges();
            }
        }
コード例 #2
0
        public static void InsertDiffObj()
        {
            var sam = new Samurai
            {
                Name = "Name1"
            };
            var bat = new Battle
            {
                Name      = "Belasica",
                StartDate = DateTime.Today.AddDays(-30),
                EndDate   = DateTime.Today
            };

            using (var db = new SamuraiDbContext())
            {
                db.AddRange(sam, bat);
                db.SaveChanges();
            }
        }
コード例 #3
0
        public static void InsertMultipleSamurai()
        {
            var list = new List <Samurai>();

            var samurai = new Samurai();

            samurai.Name = "Kire";

            var sam2 = new Samurai();

            sam2.Name = "Petar";

            list.Add(samurai);
            list.Add(sam2);
            using (var db = new SamuraiDbContext())
            {
                db.Samurais.AddRange(samurai, sam2);
                db.Samurais.AddRange(list);
                db.AddRange(samurai, sam2);

                db.SaveChanges();
            }
        }
コード例 #4
0
 private static void AddSomeMoreSamurais()
 {
     _context.AddRange(
         new Samurai {
         Name = "Kambei Shimada"
     },
         new Samurai {
         Name = "Shichirōji "
     },
         new Samurai {
         Name = "Katsushirō Okamoto"
     },
         new Samurai {
         Name = "Heihachi Hayashida"
     },
         new Samurai {
         Name = "Kyūzō"
     },
         new Samurai {
         Name = "Gorōbei Katayama"
     }
         );
     _context.SaveChanges();
 }