title: Retrieve data from multiple tables in ASP.NET MVC using Entity Framework and a repository pattern
body: <p>I have 2 classes related in my model:</p>
  
  <pre><code>public class Product
  {
          public Product()
          {
              this.Additives = new HashSet&lt;Additive&gt;();
          }
  
          public int Id { get; set; }
          public string Name { get; set; } // refrigerante
          public string CommercialName { get; set; } // nome popular, ex: fanta laranja
          public string Brand { get; set; } // marca, ex: Coca-cola
          public string Details { get; set; } // composicao, ingredientes
          public HalalState HalalState { get; set; } // estado: halal, haram ou desconhecido
          public DateTime? LastUpdate { get; set; } // date e hora do registo
  
          public ICollection&lt;Additive&gt; Additives { get; set; } // aditivos
          public int ProviderID { get; set; }
  }
  </code></pre>
  
  <p>and</p>
  
  <p>public class Provider
     {
         public Provider()
         {
             this.Products = new HashSet();
         }</p>
  
  <pre><code>   public int ProviderId { get; set; }
     public string OfficialName { get; set; } // nome usado no licenciamento
     public string PopularName { get; set; } // nome popular, mais conhecido
     public int Nuit { get; set; } //identificacao tributaria
     public EstablishmentCategory EstablishmentCategory { get; set; } // tipo de estabelecimento
     public HalalState HalalState { get; set; }
     public DateTime? LastUpdate { get; set; } // date e hora do registo
  
     public ICollection&lt;Product&gt; Products { get; set; } // lista de produtos halal               
  }
  </code></pre>
  
  <p>I'm trying to load products alongside with its provider name to display in page using Razor engine. Something like:</p>
  
  <pre><code>Product Name (from table A) | Provider Name (from table B) 
  Soft drink                  | Coca-Cola
  Chips                       | Lays
  </code></pre>
  
  <p>The method to retrieve products in class <code>ProductsRepository</code>: </p>
  
  <pre><code>public ICollection&lt;Product&gt; ReadAll()
  {       
      return context.Products.ToList();
  }
  </code></pre>
  
  <p>I need a way to navigate to <code>OfficialName</code> property of the <code>Provider</code> class, in order to display it alongside another properties of <code>Product</code> in a view. </p>