Ejemplo n.º 1
0
        protected void Application_Start()
        {
            Database.SetInitializer<MoviesContext>(new MigrateDatabaseToLatestVersion<MoviesContext, Configuration>());
            using (var context = new MoviesContext())
            {
                context.Movies.ToList();
            }

            AreaRegistration.RegisterAllAreas();

            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
        }
Ejemplo n.º 2
0
        static void Main()
        {
            var context = new MoviesContext();
            var user = context.Users
                .Where(u => u.Username == "jmeyery")
                .Select(u => new
                {
                    username = u.Username,
                    ratedMovies = u.Ratings
                        .OrderBy(r => r.Movie.Title)
                        .Select(r => new
                        {
                            title = r.Movie.Title,
                            userRating = r.Stars,
                            averageRating = r.Movie.Ratings.Average(mr => mr.Stars)
                        })
                });

            string json = JsonConvert.SerializeObject(user, Formatting.Indented);
            File.WriteAllText("../../rated-movies-by-jmeyery.json", json);
        }