Hi,

I appreciate some help on a query I'm trying to put together
(apparently I've been told its "easy in LINQ-SQL" so I'm keen to get a
NH version). I'd like this to be as performant as possible (i.e. do
the work in the DB)

I have a class relationship like this : Grandparent, parent, child.
Each class has a sort column, but its a different name.

What I want to do (in pseudo-SQL / HQL)

select distinct parent.* from parent
where parent.grandparent.id = ?
order by parent.sortcolumn

Ok, this bit is easy..... but then I also want to eager fetch all
child related to parent... something like this:

select distinct parent.* from parent
where parent.grandparent.id = ?
left join fetch parent.child order by parent.child.sortcolumn
order by parent.sortcolumn.

i.e. I want to pull back single instances of a parent, sorted by its
sortcolumn BUT ALSO pull back all childrent of the parent and sort
those child elements by their sortcolumn.

I don't care if I use HQL or criteria. Any suggestions - can I sort an
eager fetched set of children whilst also bringing back a distinct
parent row? (I know normal left join fetch into a LIST duplicates the
parent elements)?

Multi query perhaps?

Thanks
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to