public ActionResult Index() { List<Meal> allMeals; using (var context = new DinnerContext()) { allMeals = context.Meals.OrderBy(x => x.Name).ToList(); } return View(new HomeView() { AllMeals = allMeals }); }
// GET api/<controller> public List<Meal> Get() { List<Meal> recentMeals; using(var context = new DinnerContext()) { context.Configuration.LazyLoadingEnabled = false; recentMeals = context.Meals.OrderByDescending(x => x.LastAte).Take(5).ToList(); } return recentMeals; }