Hi everybody,
I've been trying to follow along the PluralSight training in ASP.NET.MVC. So, two first courses I watched and immediatelly copied everything along with Scott.
Now, in doing the 3rd part 'Razor views' he skipped some unrelated steps of prototyping a database. Since I want to continue following along the course and not just watch, I thought I will try to replicate the missed step on my own.
So, I capture this screen (see attached) and after creating the Restaurant class with just Name property and adding properties to match in the RestaurantReview class I'm having now this in the FoodDb class:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace OdeToFood.Models
{
public class FoodDb
{
static FoodDb()
{
_reviews = new List<RestaurantReview>();
_reviews.Add(new RestaurantReview
{
Body = "A fantastic culinary pleasure.",
Created = DateTime.Now,
ID = 1,
Rating = 9,
Restaurant = new Restaurant
{
Name = "Mannequin Pis"
}
});
}
}
}
E.g. exactly as shown in the slide. However, in my case _reviews are underlined with blue and I get the error message
Error 5 The name '_reviews' does not exist in the current context c:\dev\OdeToFood\OdeToFood\OdeToFood\Models\FoodDB.cs 12 13 OdeToFood
So, what exactly am I missing in my attempts to reproduce the model prototype?
If it's not broken, fix it until it is.
My Blog