var query = _db.From<Table1>()
.LeftJoin<Table1, Table2>((t1, t2) =>
t1.Col1 == t2.Col1 && t1.Col2 == t2.Col2)
.LeftJoin<Table1, Table2, Table3>((t1, t2, t3) =>
(t2.Col3 == t3.Col3 && t2.Col2 == t3.Col2) ||
(t1.Col4 == t3.Col5 && t1.Col2 == t3.Col2))
.Where(t1 => t1.Col1 == someValue && t1.Col2 == someOtherValue)
.SelectDistinct<Table3>(t3 => t3.Col5);
I am trying to do this from my C# code so I will get result but in sql it works perfectly but when I am adding OR join I am getting error like this that i need to use correlation names
The objects "Table2" and "Table2" in the FROM clause have the same exposed names.
Use correlation names to distinguish them.
Now either I have to separate them into two queries which ideally I dont want to do. Or else I found that i can use the correlation names but I tried using TableAlias but that didnt help me much