how to find group wise data and counter in linq


var result = (
                from emp in db.Employees
                where emp.companyID.Equals(companyid)
                group emp by emp.departmentID into g
                select new
                {
                    deptid = g.Key,
                    countemp = g.Count()
                }
            ).ToList();