What I understand is you want to count employees by ToSector_Id. You can do that either on database level using SQL. For that you would need to alter your service.
SELECT [ToSector_Id], Count([Employee_Id]) Employee_Count FROM EmployeeDuty
Alternatively you can use your existing GetAllEmployeeDuty() function with LINQ. Assuming the objects returned from the method map 1:1 to the database tables, this will return list of anonymous objects with the information you want:
var employeeCounts = _service.GetAllEmployeeDuty()
.GroupBy(x => x.ToSector_Id)
.Select(x => new { ToSector_Id = x.Key, EmployeeCount = x.Count() });
Edit
The previous LINQ example returns anonymous type. This cannot be returned outside the containing method. You can create your own class however:
public class EmployeeCountByToSectorId
{
public int ToSectorId { get; set; }
public int EmployeeCount { get; set; }
}
Then change the LINQ query to use your new class:
var employeeCounts = _service.GetAllEmployeeDuty()
.GroupBy(x => x.ToSector_Id)
.Select(x => new EmployeeCountByToSectorId { ToSectorId = x.Key, EmployeeCount = x.Count() });
Please note that using here is fine if your service returns IQueryable. Otherwise I would suggest you run the query on database level and create a new method in your service to return the results.