DataContext db = new DataContext(..............);
var countStd = from a in db.tbAccess
join s in db.tbStudent on a.StudentID equals s.ID
group s by s.StudentClass into g
select new
{
StudentClass = g.Key,
CountAccess = g.Sum(a => a.AccessID)
};
Code (SQL)
SELECT s.StudentClass, SUM(a.AccessID) FROM tbAccess a
INNER JOIN tbStudent s ON a.StudentID = s.ID
GROUP BY s.StudentClass