c# - Razor view claims property doesn't exist while it does on model -


this model userviewmodel:

public class userviewmodel {     public int userid { get; set; }     public int groupid { get; set; }     public virtual group group { get; set; }     public string email { get; set; }     public virtual list<favorite> favorites { get; set; } } 

i wrote these lines in user view:

@foreach (var lessonitem in model.group.lessons) {     foreach (var favoriteitem in model.favorites)     {     } } 

and result this:

compiler error message: cs1061: 'moalem.ui.web.models.userviewmodel' not contain definition 'favorites' , no extension method 'favorites' accepting first argument of type 'moalem.ui.web.models.userviewmodel' found (are missing using directive or assembly reference?)

what wrong there?

your user view, did not show entirely, seems declare @ first line:

@model moalem.ui.web.models.userviewmodel 

you didn't show userviewmodel, guess has no property named favorites.

if show relevant code, perhaps more useful answers can given.


further questions according edit: @model on top of view say? namespace of userviewmodel posted? there other errors, project containing model compile successfully? unless you're doing really special (which aren't), compiler right. problem in code.


Comments

Popular posts from this blog

How to mention the localhost in android -

php - Calling a template part from a post -