How to load related object in Entity Framework

You can use the eager loading method show below to load the related objects:


public ViewResult Index()

 {

 var products = db.Products.Include(a => a.Type).Include(a => a.Supplier);

 return View(products.ToList());

 }

 

**Eager loading strategy attempts to load all data using a single query.