Exemplo n.º 1
0
        private static void Delete()
        {
            var context = new PlutoContext();
            var course  = context.Courses.Find(6);

            context.Courses.Remove(course);

            context.SaveChanges();
        }
Exemplo n.º 2
0
        private static void Update()
        {
            var context = new PlutoContext();
            var course  = context.Courses.Find(4);

            course.Name     = "New Name";
            course.AuthorId = 2;

            context.SaveChanges();
        }
Exemplo n.º 3
0
        private static void DeleteMany()
        {
            var context = new PlutoContext();

            var author = context.Authors.Include(a => a.Courses).Single(a => a.Id == 2);

            context.Courses.RemoveRange(author.Courses);
            context.Authors.Remove(author);

            context.SaveChanges();
        }
Exemplo n.º 4
0
        private static void AddCourse()
        {
            var context = new PlutoContext();
            var author  = context.Authors.Single(a => a.Id == 1);

            var course = new Course
            {
                Name        = "New Course 2",
                Title       = "Some Title 2",
                Description = "New Description 2",
                FullPrice   = 19.95f,
                Level       = CourseLevel.Beginner,
                Author      = author
            };

            context.Courses.Add(course);
            context.SaveChanges();
        }