Example #1
0
        private static void InsertCountry()
        {
            var country = new Country
            {
                Capital = "Ottawa",
                IsSecure = true,
                Name = "Canada",
                Population = 27000000,
                TraditionnalFood = "Maple Syrup"
            };

            using (var context = new BreakAwayContext())
            {
                country.Languages = context.Languages.ToList();
                context.Countries.Add(country);
                context.SaveChanges();
            }
        }
Example #2
0
        private static void InsertDestination()
        {
            var destination = new Destination
            {
                Country = "Indonesia",
                Description = "EcoTourism at its best in exquisite Bali",
                Name = "Bali is the new place to be"
            };

            var trip = new Trip
            {
                CostUSD = 800,
                StartDate = new DateTime(2011,9,1),
                EndDate = new DateTime(2011,9,14)
            };

            var person = new Person
            {
                FirstName = "Hugo",
                LastName = "Girard",
                SocialSecurityNumber = 12345678
            };

            using (var context = new BreakAwayContext())
            {
                context.Persons.Add(person);
                context.Trips.Add(trip);
                context.Destinations.Add(destination);
                context.SaveChanges();
            }

            using (var context = new BreakAwayContext())
            {
                // Here the update behind will add a where clause to the SocialSecurity number (page 50 book Code First)
                var people = context.Persons.FirstOrDefault();
                people.FirstName = "John";
                context.SaveChanges();
            }
        }
Example #3
0
        private static void InsertLanguages()
        {
            var language = new Language
            {
                Culture = "en-US",
                Name = "English"
            };

            var language2 = new Language
            {
                Culture = "fr-FR",
                Name = "French"
            };

            using (var context = new BreakAwayContext())
            {
                context.Languages.Add(language);
                context.Languages.Add(language2);
                context.SaveChanges();
            }
        }