title: How join two tables and get count record from record with Entity Framework
body: <p>I want to use Entity Framework to join two tables and get output this result</p>
  
  <pre><code>table 1                          table2
  
  idst      name                   idtable2        idst         
  -----------------                ---------------------
  1         ali                       1              1
  2         reza                      2              1
  3         amir                      3              2 
  4         obama                     4              2
  </code></pre>
  
  <p>Desired query result:</p>
  
  <pre><code>row       name      count 
  -------------------------
  1         ali         2
  2        reza         2
  3         amir        0
  </code></pre>
  
  <p>I wrote this code:</p>
  
  <pre><code>var query = _Colorproductt.OrderBy(x =&gt; x.Productid)
                            .Skip((page - 1) * count)
                            .Take(count)
                            .Select(a =&gt; new Colormodel
                                        {
                                           Id = a.Id,
                                           Countcolorsixe = Convert.ToInt16(_sizeproductt.Where(x =&gt; x.Id == a.Id).Count().ToString()),
                                           Productid = a.Productid,
                                          PrincipleImagePath = a.PrincipleImagePath
                                        });
  </code></pre>
  
  <p>or</p>
  
  <pre><code>var q = _Colorproductt.Join(_sizeproductt, 
                              c =&gt; c.Id, p =&gt; p.color_id, 
                              (c, p) =&gt; new { ID_ProductId = c.Productid, PrincipleImagePath = c.PrincipleImagePath, Id = c.Id,  Product = p })
                        .ToList();
  </code></pre>