I want to transfer the following statement to SubSonic 2.2
SELECT b.*
FROM tableA a
INNER JOIN tableB b
ON (a.year = b.year AND a.month = b.monath AND a.userid = b.userid);
My problem is that SubSonic's SqlQuery.LeftInnerJoin() command has no overload which takes more than one column.
Since any join can be rewritten only using where clauses, I did the following in my sql:
SELECT b.*
FROM tableA a, tableB b
WHERE a.year = b.year
AND a.month = b.month
AND a.userid = b.userid
which should deliver the same result (in fact, at least for mysql, there is logically absolutely no difference between these statements).
But I also got stuck transfering this to subsonic because the "IsEqualTo(...)" member is smart enough to figure out that my parameter is a string and puts it into quotes.
DB.Select("TableB.*")
.From<TableA>()
.From<TableB>()
.Where(TableA.YearColumn).IsEqualTo("TableB.Year")
.And(TableA.MonthColumn).IsEqualTo("TableB.Month")
.And(TableA.UseridColumn).IsEqualTo("TableB.UserId")
(I tried different ways in setting the IsEqualTo parameter)
IsEqualTo(TableB.YearColumn)
IsEqualTo(TableB.YearColumn.QualifiedName)
Either the parameter is interpreted as
TableA.Year = 'TableB.Year'
or I get a SqlQueryException.
Can somebody tell me how to do this query with subsonic (Either the first - with JOIN or the second one)? Thanks