コード例 #1
0
 private static void SimpleSpaceshipQuery()
 {
     using (var context = new SpaceshipContext())
     {
         var spaceships = context.Spaceships.ToList();
         var query      = context.Spaceships;
         //var spaceshipsAgain=query.ToList();
         foreach (var spaceship in query)
         {
             Console.WriteLine(spaceship.Name);
             Console.WriteLine();
         }
     }
 }
コード例 #2
0
        private static void AddSpaceship()
        {
            var spaceship = new Spaceship {
                Name = "USCSS Nostromo"
            };
            var spaceship2 = new Spaceship {
                Name = "USS Sulaco"
            };
            var spaceship3 = new Spaceship {
                Name = "USCSS Patna"
            };
            var spaceship4 = new Spaceship {
                Name = "Narcissus"
            };

            using (var context = new SpaceshipContext())
            {
                context.Spaceships.AddRange(spaceship, spaceship2, spaceship3, spaceship4);
                context.SaveChanges();
            }
        }