How can i get a list with all the data and reference data from database from a static function? I try to use db.Configuration.LazyLoadingEnabled = true;
but the function return only the project info and the reference data was null.
public static Project GetProject(Guid ProjectID)
{
if (!ProjectID.Equals(null))
{
using (var db = new dbEntity())
{
return db.Projects.Single(Project => Project.Id.Equals(ProjectID));
}
}
return null;
}
Error:
The ObjectContext instance has been disposed and can no longer be used for operations that require a connection.
Where i call the function:
@{var project = StaticMethods.GetProject(Guid.Parse(ViewContext.RouteData.Values["id"].ToString()));}
@for(var item in project.Users().ToList()){
....
}