title: Convert stored procedure to LINQ
body: <p>I'm using MVC3 and still learning LINQ. I'm having some trouble trying to convert a query to LINQ to Entities. I want to return an Json method</p>
  
  <p>My stored procedure </p>
  
  <pre><code>Create Procedure [dbo].[ResourceReports]
  (
      @EmployeeID int
  ) 
  as
  begin
      select   p.projectName AS Projects,  count( b.[CreatedByID]) AS Bugs
      from [EmployeeDetails] e inner join [Bugs] b  on e.[EmployeId] = b.[CreatedByID]
      inner join Projects p on b.ProjectId = p.ProjectId
      where e.[EmployeId] = @EmployeeID   
      group by P.projectName
  end 
  </code></pre>
  
  <p>What I have is a few tables, I started writing this out in LINQ but I'm not sure how to properly return the correct type or cast this.</p>
  
  <p>My controller </p>
  
  <pre><code>public JsonResult Getchart()
  {
      var Bug = db.Bugs.ToList&lt;Bug&gt;();
      var EmployeDetails = db.EmployeeDetails.ToList&lt;EmployeeDetail&gt;();
      var projects = db.Projects.ToList&lt;Project&gt;();
  
      var result = (from e in EmployeDetails 
                    join b in Bug on e.EmployeId equals b.CreatedByID
                    join p in projects on b.ProjectId equals p.ProjectId
                    where e.EmployeId = @EmployeId
                    group p.projectName
                    select new (p.projectName as Project ,count(b.CreatedByID) as Bug)).Take(50);
  
      return Json(result,JsonRequestBehavior.AllowGet);
  }
  </code></pre>
  
  <p>How will I pass the parameter to for the query, want the data to be returned in json format.</p>