我有以下查询在 SSMS 中运行良好。我正在使用 LinqPad ( C# ),但在 LinqToSql 中成功使用左外连接真的令人费解:
SELECT DISTINCT
A.LocID,
V1.PrfValue AS pID,
V2.PrfValue AS sID,
D.DivisionManager,
A.IsApproved,
A.DateCreated
FROM
dbo.Locations AS A
INNER JOIN
dbo.Divisions AS D
ON A.DivisionID = D.DivisionID
LEFT OUTER JOIN
dbo.ValuesInLocations AS V1
ON A.LocID = V1.LocID
AND
V1.PrfID IN (SELECT
PrfID
FROM
dbo.PrfTag
WHERE
(LevelTypeID = 1))
LEFT OUTER JOIN
dbo.ValuesInLocations AS V2
ON A.LocID = V2.LocID
AND
V2.PrfID IN (SELECT
PrfID
FROM
dbo.PrfTag
WHERE
(LevelTypeID = 2))
如您所见,这不是开始工作的最优雅的查询,我同意两个左连接中的子查询可以改进。但是,你能帮我翻译一下吗?