1

我在 TSQL 中有这个查询,我想把它转换成 LINQ。请帮我转换这个。先感谢您。:)

enter code here

declare @EmployeeId as varchar(10)

set @EmployeeId = 'P24710002'

SELECT [HCIS_ID] 
WHERE [OHCD_EmployeeInfo].[HCIS_ID]=[OHCD_PersonalData].HCIS_ID) 
as ImmediateSupervisor 
,[LastName] 
,[FirstName] 
,[MiddleName] 
FROM [OHCD_PersonalData] 
Where (((HCIS_ID in 
(Select HCIS_ID From OHCD_employeeInfo Where ImmediateSupervisor = 
(Select HCIS_ID From OHCD_employeeInfo Where EmployeeID = @EmployeeId))) 
or 
(HCIS_ID in (Select HCIS_ID From OHCD_employeeInfo Where NextLevelSupervisor 
= (Select HCIS_ID From OHCD_employeeInfo Where EmployeeID = @EmployeeId)))) 
or (hcis_id in (select hcis_id from ohcd_employeeinfo where 
(ImmediateSupervisor = (Select HCIS_ID From OHCD_employeeInfo Where 
EmployeeID =  @EmployeeId) 
or NextLevelSupervisor = 
(Select HCIS_ID From OHCD_employeeInfo Where EmployeeID =   @EmployeeId))) 
or hcis_id in (select hcis_id from ohcd_employeeinfo Where 
ImmediateSupervisor in 
(select hcis_id from ohcd_employeeinfo where (ImmediateSupervisor = 
(Select HCIS_ID From       OHCD_employeeInfo Where 
EmployeeID = @EmployeeId) 
or NextLevelSupervisor = (Select HCIS_ID From OHCD_employeeInfo 
Where EmployeeID =   @EmployeeId)))) 
or hcis_id in (select hcis_id from ohcd_employeeinfo Where NextLevelSupervisor 
in (select hcis_id from ohcd_employeeinfo where (ImmediateSupervisor = 
(Select HCIS_ID    From OHCD_employeeInfo Where EmployeeID = @EmployeeId) 
or  NextLevelSupervisor = (Select HCIS_ID From OHCD_employeeInfo 
Where EmployeeID =   @EmployeeId)))) 
or hcis_id in (select hcis_id from ohcd_employeeinfo Where ImmediateSupervisor 
in (select   hcis_id from ohcd_employeeinfo Where NextLevelSupervisor 
in (select hcis_id   from ohcd_employeeinfo where (ImmediateSupervisor = 
(Select HCIS_ID   From OHCD_employeeInfo Where EmployeeID = @EmployeeId) 
or NextLevelSupervisor = 
(Select HCIS_ID From OHCD_employeeInfo Where EmployeeID = @EmployeeId))))) 
or hcis_id in (select hcis_id from ohcd_employeeinfo Where NextLevelSupervisor 
in (select  hcis_id from ohcd_employeeinfo Where NextLevelSupervisor 
in (select hcis_id from ohcd_employeeinfo where (ImmediateSupervisor = 
(Select HCIS_ID From OHCD_employeeInfo Where EmployeeID = @EmployeeId) 
or NextLevelSupervisor = 
(Select HCIS_ID From OHCD_employeeInfo Where EmployeeID = @EmployeeId)))))))

主要原因是员工从经理到他/她的下属的层次结构。

4

0 回答 0