views:

54

answers:

1

I have a reference to call that may or may not be there. When I add the nullable option it still doing Inner Join when I want an Left Join (show the left even if the right is null). Is this possible in the NH map?

References(x => x.DefaultCategory, "CATEGORY_ID")
    .Nullable();
A: 

The join type isn't specified in the mapping, but in the query.

IN HQL, use left join syntax as with SQL.

With Criteria, use:

.CreateAlias("categories", "c", JoinType.LeftOuterJoin) 
James L
So you can never have a many-to-one reference that is null? That seems a bit odd.
Colin Bowern
What you are suggesting works, but I question is there a better way? I would be putting what feels like mapping logic into my repository thus causing a maintainability issue, no?
Colin Bowern
It isn't mapping, it's query logic. It's just as valid to perform an inner join here, but it depends on the requirements of your app
James L