I have class like this:
public class Lugar
{
    [Key]
     public int LugarId { get; set; }
    public List<Review> Reviews { get; set; }
    public int SumReviews { get; set; }
    public double AverageReviews { get {
        if (Reviews == null)
            return 0;
        else if (Reviews.Count == 0)
            return 0;
        else  
        return (double)SumReviews/(Reviews.Count); } }
}
And in my controller I have this:
 [HttpPost, Authorize]
    public ActionResult WriteReview(int id, FormCollection formCollection)
    {
        Lugar lugar = db.Lugares.Find(id);
                    Review review=new Review();
        review.User = User.Identity.Name;
        review.Rating=Convert.ToInt32(formCollection["Rating"]);
        review.Texto = formCollection["Review"];
        if (lugar != null)
        {
            if(  lugar.Reviews==null)
            lugar.Reviews=new List<Review>();
            lugar.Reviews.Add(review);
            lugar.SumReviews += review.Rating;
            db.SaveChanges();
        }
        else
            return RedirectToAction("Index");
        return RedirectToAction("Index");
    }
}
The problem is in the line:
if( lugar.Reviews==null) lugar.Reviews=new List();
Everytime I execute I am getting ( lugar.Reviews==null) as true.....
Even if I already added a Review for that place, the if statement returns true.....
 
     
     
     
     
    