title: how to write linq "group by" and get count based on row in asp.net mvc
body: <p>I have two tables  timesheet and timesheet_log </p>
  
  <p>In timesheet i have three columns id,comp_id,emp_id and in timesheet_log table,
  i have three columns id, timesheet_id, stat.</p>
  
  <p>Now I want to group all the "STAT" column by "COMP_ID", for that i wrote query in sql</p>
  
  <pre><code>select tlog.stat,count(*) as count  from  timesheet ts
  join
  timesheet_log  tlog on ts.id = tlog.timesheet_id
  where comp_id=10//For ex.
  group by tlog.stat
  </code></pre>
  
  <p>In stat column contains each rows like "Not_Entered","Not_submitted" etc..,
  when i executing above query in sql server,i getting result like</p>
  
  <p>result:<br/>
  <b>Stat</b> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;   <b>Count</b><br/>
  Not_entered     &nbsp; &nbsp; &nbsp;  10 <br/>
  Not_Submitted   &nbsp; &nbsp; 8...<br/>
  ..................<br/>
  -------------------<br/></p>
  
  <p>Now, I want to write the query in linq and assign variable count of each row to a varaible like:</p>
  
  <p>if Not_entered count in 10 then<br/>
  int emp_not_entered= //Count of Not entered.</p>
  
  <p>I have tried in linq like </p>
  
  <pre><code>        var result= (from timesheet in reslandentity.TIMESHEET
                                  join tlog in reslandentity.TIMESHEET_LOG on timesheet.ID equals tlog.TIMESHEET_ID
                                  group tlog by tlog.STAT into g
  
                                  select   g).ToString();
  </code></pre>
  
  <p>But not getting what i expected, Help me anyone</p>