예제 #1
0
        public static void AddCourseWithAuthorId()
        {
            using (var context = new PlutoContext())
            {
                var courseWithAuthorId = new Course
                {
                    Name        = "Course with author id",
                    Description = "Descrpition",
                    FullPrice   = 19.95f,
                    Level       = Course.CourseLevel.Beginner,
                    AuthorId    = 1
                };

                context.Add(courseWithAuthorId);
                context.SaveChanges();
            }
        }
예제 #2
0
        public static void AddCourseWithAuthorObject()
        {
            using (var context = new PlutoContext())
            {
                var author = context.Authors.Single(q => q.Id == 1);
                var courseWithAuthorObject = new Course
                {
                    Name        = "Course with author object",
                    Description = "Descrpition",
                    FullPrice   = 19.95f,
                    Level       = Course.CourseLevel.Beginner,
                    Author      = author
                };

                context.Add(courseWithAuthorObject);
                context.SaveChanges();
            }
        }
예제 #3
0
 public void Create(T entity)
 {
     _context.Add(entity);
     // Save();
 }