Nhibernate DetachedCriteria Left Outer Join subquery

I will try to present the main part of the problem, because the whole situation is much more complicated - I cannot achieve the following with DetachedCriteria

SELECT *
FROM User
LEFT OUTER JOIN GroupItem
ON User.ID = GroupItem.UserID
AND _groupItemRestrictions_

      

There can be multiple GroupDefinitions, A user can belong to multiple GroupItems, each of which belongs to its own GroupDefinition. Due to some tricky reason related to paging / sorting and (layered) grouping behavior, I am unable to achieve the appropriate paging behavior with this query:

SELECT *
FROM User
LEFT OUTER JOIN GroupItem
ON User.ID = GroupItem.UserID
WHERE _groupItemRestrictions_

      

A request similar to the second is created as follows:

var criteria = DetachedCriteria.For<User>()
...
GroupItem groupItem = null;
criteria.CreateAlias(() => groupItemAlias, () => groupItem,
                                                JoinType.LeftOuterJoin);
criteria.Add(Restrictions.Or(...));
...

      

Is it possible to create the first request with DetachedCriteria?

Thank!

+2


source to share


1 answer


It looks like there is no way yet to specify such a query using DetachedCriteria, but there is an HQL using the "with" clause:

http://fabiomaulo.blogspot.com/2009/05/nhibernate-210-hql-with-clause.html

http://www.mail-archive.com/ nhusers@googlegroups.com /msg08451.html



UPDATE:

https://nhibernate.jira.com/browse/NH-1946

This feature has now been implemented. Thanks to the NH team :)

+2


source







All Articles