我寫了一個T-SQL
代碼,它在選擇範圍內使用過大小寫。我們不能在應用程序中使用t-sql或存儲過程,因爲我需要將follong代碼轉換爲LINQ
。
有沒有什麼辦法可以很快的將這段代碼改成linq?如何在LINQ中實現CASE?
SELECT
T.TaskID,
SUM(CASE WHEN T.LogDate<@fromDate AND T.TaskStatusID=2 THEN ISNULL(DA_CHILD.Score,0)*(T.DoneScore/100) ELSE 0 END) PreAmount,
SUM(CASE WHEN T.LogDate>[email protected] AND T.LogDate<[email protected] AND T.TaskStatusID=2 THEN ISNULL(DA_CHILD.Score,0)*(T.DoneScore/100) ELSE 0 END) CurAmount
FROM
NetTasks$ T
INNER JOIN NetDeviceActions DA ON DA.DeviceActionID=T.DeviceActionID
LEFT JOIN NetFinancialInfoDetail FID ON FID.TaskID=T.TaskID
INNER JOIN NetActionParents AP ON AP.ParentID=DA.ActionID
INNER JOIN NetDeviceActions DA_CHILD ON DA_CHILD.ActionID=AP.ChildID AND
DA_CHILD.DeviceID=DA.DeviceID AND
DA_CHILD.ContractInfoID=DA.ContractInfoID
WHERE
T.ParentTaskID = 0 AND
T.FinishDate<[email protected] AND
DA.ContractInfoID=9
GROUP BY
T.TaskID, T.DoneScore,T.FinishDate
如何在LINQ上實現三重條件? –