I've this SQL query:
SELECT D.ID
FROM Documents AS D
INNER JOIN DocClasses AS DC WITH (NOLOCK)
ON D.DocClass = DC.ID
INNER JOIN DocSubClasses AS DSC WITH (NOLOCK)
ON D.DocSubClass = DSC.ID AND DSC.DocClassID = DC.ID
INNER JOIN DocPathFolders AS F WITH (NOLOCK)
ON D.DocPathFolderID = F.ID
WHERE
DC.ShortName = 'PAY' AND DSC.Name = 'xxxxx'
AND UPPER(F.Description) = 'READY TO SEND'
I'm trying to convert this query into LINQ. Here is what I've done so far:
from D in ctx.Documents
join DC in ctx.DocClasses on D.DocClass equals DC.ID
join DSC in ctx.DocSubClasses
on new { D.DocSubClass, DSC.DocClassID } equals new { DSC.ID, DC.ID }
join F in ctx.DocPathFolders
on D.DocPathFolderID equals F.ID
where
DC.ShortName == "PAY"
&& DSC.Name == "xxxxx"
&& (F.Description).ToUpper() == "READY TO SEND"
select D.ID;
I'm getting error in this line:
join DSC in ctx.DocSubClasses on new { D.DocSubClass, DSC.DocClassID } equals new { DSC.ID, DC.ID }
Here, I'm getting following error:
The name 'DSC' is not in scope on the left side of 'equals'
The name 'DC' is not in scope on the right side of 'equals'
I'm new in LINQ and that's why I can't solve these error. I would apperciate any suggestion on the above. Thanks.