예제 #1
0
        private static void AddSpaceship(string name)
        {
            var spaceship = new Spaceship {
                Name = name
            };

            using (var context = new SpaceshipContext())
            {
                context.Spaceships.Add(spaceship);
                context.SaveChanges();
            }
        }
예제 #2
0
        private static void AddRavioliForSpaceship(string name, int number, DateTime packed)
        {
            var spaceship = new Spaceship
            {
                Name = name,
                RavioliInSpaceship = new List <RavioliInSpaceship>
                {
                    new RavioliInSpaceship {
                        Ravioli = new Ravioli
                        {
                            Packed = packed
                        }
                    }
                }
            };

            using (var context = new SpaceshipContext())
            {
                context.Spaceships.Add(spaceship);
                context.SaveChanges();
            }
        }