コード例 #1
0
        static void Main(string[] args)
        {
            ///
            /// Section 3 Examples
            ///
            //var context = new PlutoDbContext();

            //var courses = context.GetCourses();
            //foreach(var c in courses)
            //{
            //    Console.WriteLine(c.Title);
            //}

            //var course = new Course();
            //course.Level = Level.Beginner; // 1


            ///
            /// Section 3 Exercise '1st Iteration'
            /// See '_Extras' for documents regarding this Exercise
            ///

            var context = new VidzyDbContext();

            //var comedyGenre = context.Genres.SingleOrDefault(g => g.Name == "Comedy");
            //var actionGenre = context.Genres.SingleOrDefault(g => g.Name == "Action");

            //context.AddVideo("Hang Over", new DateTime(2009, 6, 2), comedyGenre.Name);
            //context.AddVideo("Die Hard", new DateTime(1988, 7, 15), actionGenre.Name);
            //context.AddVideo("Matrix", new DateTime(1999, 3, 31), actionGenre.Name);
            //context.AddVideo("Deadpool 2", new DateTime(2018, 5, 10), comedyGenre.Name);

            // Be careful of uncommenting multiple SaveChanges() calls
            //context.SaveChanges();

            ///
            /// Section 3 Exercise '2nd Iteration'
            /// See '_Extras' for documents regarding this Exercise
            ///

            var familyGenre = context.Genres.SingleOrDefault(g => g.Name == "Family");

            //context.AddVideo("Toy Story", new DateTime(1995, 11, 22), familyGenre.Name);

            //context.SaveChanges();

            ///
            /// Section 3 Exercise '3rd Iteration'
            /// See '_Extras' for documents regarding this Exercise
            ///

            var romanticGenre = context.Genres.SingleOrDefault(g => g.Name == "Romance");

            context.AddVideo("Titanic", new DateTime(1995, 11, 22), romanticGenre.Name, Classification.Platinum);
            context.AddVideo("Toy Story 2", new DateTime(1999, 11, 13), familyGenre.Name, Classification.Gold);
            context.AddVideo("Snow White", new DateTime(1952, 2, 13), romanticGenre.Name, Classification.Silver);

            context.SaveChanges();
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: yliu108/Entity
        static void Main(string[] args)
        {
            var dbContext = new VidzyDbContext();

            dbContext.AddVideo("testing", DateTime.Now, "Horror", (byte)Classification.Platinum);
            dbContext.AddVideo("testing2", DateTime.Now, "Comedy", (byte)Classification.Gold);
            Console.Read();
        }