I am having two object classes
public class User
{
public Guid Id { get; set; }
public string Name { get; set; }
// Navigation
public ICollection<Product> Products { get; set; }
}
public class Product
{
public Guid Id { get; set; }
// Navigation
public User User { get; set; }
public Guid User_Id { get; set; }
public string Name { get; set; }
}
When i load a user using dataContext, i get the list of Products being null (this is ok).
If i add "virtual" keyword to Products list,
public virtual ICollection<Product> Products { get; set; }
when i load the user, i get the Products list as well.
Why is this happening? I thought that "virtual" keyword is used for not loading the entities unless you explicit this (using an "Include" statement)
I think i got it all wrong