How do I convert this SQL to Lambda expression:
SELECT L.LotNo,
L.ProcessCode,
L.ProcessName,
L.MachineNo,
M.MaterialLotNo,
M.MaterialName,
M.StartTime,
M.EndTime
FROM LotProgress L
INNER JOIN MaterialMount M
ON (M.MachineNo = L.MachineNo OR M.MachineNo =
(SELECT ParentMachineNo FROM Machine WHERE MachineNo = L.MachineNo))
AND (L.StartTime <= M.EndTime OR M.EndTime IS NULL)
AND (L.EndTime >= M.StartTime OR L.EndTime IS NULL)
I am struggluing to convert the multiple condition on Inner Join. This is as far as I can go:
var vewMaterialTrace = viewLotProgress
.Join(viewMaterialMount, a => a.MachineNo, b => b.MachineNo,
(a, b) => new viewMaterial
{
LotNo = a.LotNo,
ProcessCode = a.ProcessCode,
ProcessName = a.ProcessName,
MachineNo = a.MachineNo,
OpeGroupCode = b.OpeGroupCode,
OpeGroupName = b.OpeGroupName,
MaterialLotNo = b.MaterialLotNo,
MaterialName = b.MaterialName,
StartTime = b.StartTime,
EndTime = b.EndTime,
}).ToList();
OR M.MachineNo = (SELECT ParentMachineNo FROM Machine WHERE MachineNo = L.MachineNo))is correct or not, because the subquery may return a list