i have two table Employeestatus and EmployeeCategory
i am using following query to get my data, its working ok but i need modification in it . new query IN EF
var sectorEmployees = from ec in entities.EmployeeCategories.Where(x => x.Category_Id == 1 || x.Category_Id == 2
&& x.Sector_Id == sectorId)
join es in entities.EmployeeStatus.Where(x => x.EmployeeStatusType_Id == 1)
on ec.Employee_Id equals es.Employee_Id
select es;
BUT problem is that there are multiple record against one employee but i want last records of that employee from the table, i was using following query that was fullfilling my needs
var sectorEmployees = _service.GetEmployeeStatusBySector_Id(sectorId).OrderByDescending(x => x.EndDate)
.GroupBy(x => x.Employee_Id).Select(x => x.LastOrDefault()).ToList();
how can i can modify 1st query to full fill my needs that is done by 2nd query.