If you would like to group data by department, you have to use proper field, such as
DepartmentID
:
var names = dt.AsEnumerable()
.GroupBy(emp=>emp.Field<int>("DepartmentId"))
.Select(grp=> new
{
DeptId = grp.Key,
});
For further details, please see:
101 LINQ Samples in C#[
^]
Linq 101 lambda samples[
^]