title: Convert Linq to SQL
body: <p>I have researched on the net and most result are converting from sql to linq and seldom have linq to sql.</p>
  
  <p>this is the code which I want to convert to SQL : </p>
  
  <pre><code> using (CommerceEntities db = new CommerceEntities())
      {
      try
        {
        var query = (from ProductOrders in db.OrderDetails
                          join SelectedProducts in db.Products on ProductOrders.ProductID  
                          equals SelectedProducts.ProductID
                          group ProductOrders by new
                              {
                              ProductId = SelectedProducts.ProductID,
                              ModelName = SelectedProducts.ModelName
                              } into grp
                          select new
                              {
                              ModelName = grp.Key.ModelName,
                              ProductId = grp.Key.ProductId,
                              Quantity = grp.Sum(o =&gt; o.Quantity)
                              } into orderdgrp where orderdgrp.Quantity &gt; 0 
                          orderby orderdgrp.Quantity descending select orderdgrp).Take(5);
  
                      RepeaterItemsList.DataSource = query;
                      RepeaterItemsList.DataBind(); 
        }
      catch (Exception exp)
        {
        throw new Exception("ERROR: Unable to Load Popular Items - " + 
                             exp.Message.ToString(), exp);
        }
      }
  </code></pre>