Linq2NHibernate - only left connections?

Really quick question ..

Does Linq2NHibernate always create a left join to extract relationships? Is there a way so that I can get internal?

Thanks in advance.

Philip

+4
source share
1 answer

As far as I know.

For any relationship that is not a one-to-one relationship, NHibernate makes the assumption that the relationship can have from 0 to many results, so it uses Left Join.

I don't know about Linq2NHibernate, but in NH3 using the QueryOver API you can specify connection types.

For example, select Product with a category. If you wrote:

var result = Session.QueryOver<Product>() .Fetch(x => x.Category).Eager .List(); 

This will lead to a left join, if you want to specify an inner join, you can write the same query as:

 var result = Session.QueryOver<Product>() .JoinQueryOver(x => x.Category, JoinType.InnerJoin) .List(); 

This will lead to Inner Join.

As far as I know, you cannot specify connection types when using the LINQ provider ( Query<T> in NH3)

+1
source

All Articles