title: How to join multiple tables in entity framework
body: <p>I have below code where I am using entity framework,</p>
  
  <pre><code>public IEnumerable&lt;Product&gt; GetProducts()
  {
      var query = (from p in db.Products
                       join pd in db.ProductDetails
                           on p.ProductID equals pd.ProductID
                       select new
                       {
                           p.ProductName,
                           pd.IsEnabled
                       }).ToList();
  
          IEnumerable&lt;Product&gt; products =
              db.Products.Include(x =&gt; x.ProductDetail).ToList();
  
          return products;
  }
  
  
  public partial class Product
  {
      public int ProductID { get; set; }
      public string ProductName { get; set; }
      public System.DateTime CreatedDate { get; set; }
  
      public virtual ProductDetail ProductDetail { get; set; }
  }
  </code></pre>
  
  <p>Instead of returning data from only Products table, I want to return data from ProductDetails table as well.</p>
  
  <p>Also, if I want to add where clause here, how would I do that? </p>
  
  <p>I tried Something like this but it doesn't work, </p>
  
  <pre><code>public IEnumerable&lt;ProductEnableInfo&gt; GetProducts(int pid) 
  { 
     return db.Products.Select( x =&gt; new ProductEnableInfo 
                                   { ProductId = x.ProductID,
                                     ProductName = x.ProductName, 
                                     IsEnabled = x.ProductDetail.IsEnabled 
                                   }).Where(x =&gt; x.ProductId == pid) .ToList(); 
  }
  </code></pre>
  
  <p>How can I do that?</p>