I am using Entity Framework 5 code first and ASP.NET MVC 3 .
I am struggling to populate a child of a child. Below are my lessons.
Application class
public class Application {
Child class:
public class Child {
ChildRelationshipType Class:
public class ChildRelationshipType { public int Id { get; set; } public string Name { get; set; } }
Part of the GetAll method in the repository returns all applications:
return DatabaseContext.Applications .Include("Children");
The Child class contains a reference to the ChildRelationshipType class. For working with child applications, I would have something like this:
foreach (Child child in application.Children) { string childName = child.ChildRelationshipType.Name; }
I get an error here that the object context is already closed.
How to indicate that each child should include a ChildRelationshipType object, like what I did above?
Brendan Vogt Oct 24 '12 at 10:59 2012-10-24 10:59
source share