I have 3 Entities (MasterDoc, Folder, User) that i link together in another Entity (Folder_User).
public class Folder_User
{
public int Id { get; set; }
public MasterDoc MasterDoc { get; set; }
public User User { get; set; }
public Folder Folder { get; set; }
}
After ive inserted an object of type Folder_User into the database, i can (on the same DbContext) query it and retreive the child objects.
public static List<Folder_User> GetAllFolder_USer(User user, DataModel dbContext)
{
List<Folder_User> list = null;
var query = from f in dbContext.Folder_User
where f.User.Id == user.Id
select f;
list = new List<Folder_User>(query);
return list;
}
But after a page-refresh (new dbcontext) when i run the same query the objects reference to MasterDoc is null.
*I have tried turn of lazy loading but nothing seems to fix it.
*Have also checked the database and the table is correctly containing a row with a MasterDoc Id.
You need to
IncludetheMasterDocin the query: