This would be written in LINQ as:
using(var dc = new MyDataContext())
{
var q = from t in Transactions
join ts in TransactionSamples
on (t.ParentTransactionID ?? t.TransactionID)
equals ts.TransactionID
into joined
where t.TransactionID = 12345
select joined;
}
In your example, you are using a CASE
to fall back to a non-null value, which is really the same as a COALESCE(case1, case2)
:
SELECT ...
FROM [dbo].[Transactions] AS [t0]
LEFT OUTER JOIN [dbo].[TransactionSamples] AS [t1]
ON (COALESCE([t0].[ParentTransactionID],[t0].[TransactionID])) = [t1].[TransactionID]