public List GetEmployeeTransferListForHR(TimecardDataContext TimecardDC)
{
List objEmployee
Get Distinct using GroupBy
objEmployeeTransferList.GroupBy(x => x.empId).Select(g => g.First()).ToList();
There is a distinct method in linq which should do the trick.
http://msdn.microsoft.com/en-gb/library/bb348436.aspx
Have you try:
objEmployeeTransferList = TimecardDC.MAS_EMPLOYEE_TRANSFER.Where(
employee => employee.HR_ADMIN_IND=="Y").Distinct().ToList();
Have try making it
.Distinct().ToList();
You can refer here LINQ: Distinct values
List<int> ids = objEmployeeTransferList
.Select(e => e.empId)
.Distinct()
.ToList();
Also you can make this on server side without creating in-memory employee list with all admin records:
List<int> ids = TimecardDC.MAS_EMPLOYEE_TRANSFER
.Where(e => e.HR_ADMIN_IND == "Y")
.Select(e => e.empId)
.Distinct()
.ToList();