我有一张table
SELECT JM.jobNum+'.'+CONVERT(VARCHAR,TL.tlPhasenum) AS [COST CODE],EM.empnum+'‌' AS [EMPLOYEE NUMBER],TL.tlDateWorked AS [DATE],tl.tlOT,tl.tlStraightTime INTO #TempTable
FROM mqTimeReportingTimeLogs AS TL
INNER JOIN mqJobMaster AS JM ON TL.tlJobId=JM.jobId
INNER JOIN mqEmployeeMaster AS EM ON TL.tlEmployeeId=EM.empId
WHERE
TL.tlCompanyId in (select * from #TempCompanies)
AND (@weekending='' or tlWeekEnding=CONVERT(DATE,@weekending))
AND (@jobid=0 or TL.tlJobId=@jobid)
AND (@startdate='' or TL.tldateworked between convert(date,@startdate) and convert(date,@enddate))
以及以下要拆分为两行的查询
SELECT * INTO #TempTable2
FROM (
SELECT [COST CODE],[EMPLOYEE NUMBER],[DATE],value as [Hours],col as [Time Type]
from #TempTable
CROSS APPLY
(
VALUES('1',tlStraightTime),('2',tlOT) --1:ST 2:OT
) C (COL, VALUE)
) SRC
现在我想在linq中实现同样的事情,如何在linq中使用这个逻辑
1条答案
按热度按时间yeotifhr1#
一旦你翻译了
TempTable
查询到linq,类似于:然后,您可以通过使用
Select
以及Concat
(例如。SELECT
以及UNION ALL
)哪些linq到sql可以转换: