示例#1
0
        static void RemoveData()
        {
            var context = new PlutoContext();
            var course  = context.Courses.Find(6);

            context.Courses.Remove(course);

            context.SaveChanges();
        }
示例#2
0
        static void UpdateData()
        {
            var context = new PlutoContext();
            var course  = context.Courses.Find(1);

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

            context.SaveChanges();
        }
示例#3
0
        static void AddingData()
        {
            var context = new PlutoContext();
            var author  = context.Authors.Single(a => a.Id == 1);

            var course = new Course
            {
                Name        = "New Course",
                Description = "New Description",
                FullPrice   = 19.95f,
                Level       = 1,
                Author      = author
            };

            context.Courses.Add(course);

            context.SaveChanges();
        }