Exemplo n.º 1
0
        private void InsertUserRatingData()
        {
            using (var context = GetContext())
            {
                var movies = context.MovieDbSet.ToList();

                var user    = new Repo.User();
                var ratings = new List <Repo.MovieRating>();

                movies.ForEach(m =>
                {
                    ratings.Add(new Repo.MovieRating {
                        MovieId = m.Id, Rating = (byte)m.Id
                    });
                });
                user.MovieRatings = ratings;

                context.Add(user);

                user    = new Repo.User();
                ratings = new List <Repo.MovieRating>();

                ratings.Add(new Repo.MovieRating {
                    MovieId = movies.First().Id, Rating = 10
                });
                ratings.Add(new Repo.MovieRating {
                    MovieId = movies.Last().Id, Rating = 9
                });

                context.Add(user);

                context.SaveChanges();
            }
        }
Exemplo n.º 2
0
 private void InsertUser()
 {
     using (var context = GetContext())
     {
         var user = new repo.User();
         context.Add(user);
         context.SaveChanges();
     }
 }