How to left join with multiple "on" conditions
How to left join with multiple "on" conditions
I am attempting to set up a left join where there are two "on" equalities.
In T-SQL, I could write this:
SELECT w.WeekDescription
FROM dbo.FridayPlanning p
LEFT JOIN dbo.WeekList w
ON p.QuarterNumber = w.[Quarter]
AND p.WeekNumber = w.[Week]
I have been looking through the examples on the Joins page, but I am not sure how to indicate multiple on statements in .LeftJoin("table","field1","=","field2")
Is this type of join possible?
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
I looked in the source code (i.e., Editor.cs) in hopes I could find a function I could extend, but I had no such luck.
In Linq, I could do multiple "on" conditions like in the example below. I was hoping I could do something along these lines.
This thread contains a hack to allow this to work in PHP. I haven't tried it on .NET, but I don't see any reason why it wouldn't work.
Allan
@Allan -- Thanks. I was able to translate that hack into C# and verified that it works in my scenario. I've translated that answer into a set of formulas using generic names. Could we place this in documentation?
No - not yet. I'm not certain that I want to maintain that API or offer a different more formal way of doing it. As I mentioned this is a hack for the moment. I expect it to continue working, but it might not if I do formalise the API for it.
Allan