コード例 #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();
 }