I created a MSSQL database with tables containing foreign keys. I then created a new MVC 4 web application. I used Entity Framework to generate my controllers/models/views. In the models, tables that were linked using foreign keys appear as ICollections. For example:
public partial class Test
{
public Test()
{
this.Questions = new HashSet<Question>();
this.Users = new HashSet<User>();
}
public int testId { get; set; }
public string name { get; set; }
public string description { get; set; }
public Nullable<int> pointValue { get; set; }
public Nullable<int> numberOfQuestions { get; set; }
public virtual ICollection<Question> Questions { get; set; }
public virtual ICollection<User> Users { get; set; }
}
}
My question is how am I able to access the data stored in those ICollections in a view? Test.Questions[x] <-- gives errors.