I have a problem with Nhibernate - it puts right join in the middle of other joins. Here is my code:
private DetachedCriteria GetBaseCriteria()
{
return DetachedCriteria.For<Foo>("foo")
.CreateAlias("foo.Bar", "bar")
.CreateAlias("bar.Baz", "baz", JoinType.InnerJoin);
}
public void Method()
{
var criteria = GetBaseCriteria();
criteria.CreateAlias("foo.Something", "something", JoinType.RightOuterJoin);
...
}
And the resulting SQL is
SELECT *
FROM foo
INNER JOIN bar ON ...
RIGHT OUTER JOIN something s ON ...
INNER JOIN baz ON ...
WHERE ...
Unfortunately, result of that query is different from the desired
SELECT *
FROM foo
INNER JOIN bar ON ...
INNER JOIN baz ON ...
RIGHT OUTER JOIN something s ON ...
WHERE ...
I have tried to change the order of the aliases in the GetBaseCriteria - but with no luck...