views:

976

answers:

1

Hi!

I'll only try to present the main part of the problem, because the whole situation is much more complicated - I am unable to achieve the following with DetachedCriteria

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

There can be multiple GroupDefinitions, User can belong to multiple GroupItems which each belong to it's own GroupDefinition. Due to some complicated reason with paging/sorting and (multilevel) group behavior, I cannot achieve appropriate paging behavior with this query:

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

A query similar to the second one is produced this way:

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 query with DetachedCriteria?

Thanks!

+1  A: 
Darjan