title: How to join two tables using LINQ?
body: <p>i am trying to join two tables  using the mvc4 web API and linq.</p>
  
  <p>This is the class code for catagory table.</p>
  
  <pre><code> public partial class catagory
  {
      public int id { get; set; }
      public string cat_name { get; set; }
      public Nullable&lt;int&gt; measure_type { get; set; }
      public Nullable&lt;int&gt; active { get; set; }
      public Nullable&lt;int&gt; parent_cat { get; set; }
      public Nullable&lt;int&gt; display_order { get; set; }
      public string cat_image { get; set; }
  }
  </code></pre>
  
  <p>code of the class for product table</p>
  
  <pre><code>public partial class product
  {
      public int id { get; set; }
      public string p_name { get; set; }
      public Nullable&lt;int&gt; price { get; set; }
      public Nullable&lt;int&gt; catagory_id { get; set; }
      public Nullable&lt;int&gt; brand_id { get; set; }
      public Nullable&lt;int&gt; active { get; set; }
      public Nullable&lt;int&gt; discount_percent { get; set; }
      public Nullable&lt;int&gt; display_order { get; set; }
      public Nullable&lt;int&gt; color_id { get; set; }
      public Nullable&lt;int&gt; seller_id { get; set; }
      public int selling_price { get; set; }
  }
  </code></pre>
  
  <p>I want to join these two table. here is the code in the ProductController.cs file</p>
  
  <pre><code> public class ProductController : ApiController
  {
  
      public List&lt;product&gt; GetProductByColour(int id)
      {
          var query = (from x in db.products.AsEnumerable()
                       join y in db.catagories.AsEnumerable()
                       on x.id equals y.id
                       where x.id.Equals(id)
                       select new product
                       {
                           id = x.id,
                           p_name = x.p_name,
                           price = x.price,
                           catagory_id = y.id,
                           brand_id = x.brand_id,
                           display_order = y.display_order,
  
                       }).ToList();
          return query.ToList();
      }
  </code></pre>