I'm trying to figure out how to do complicated queries in NHibernate.
I'm trying to refactor a Stored Proc that populates a grid to an
NHibernate query, but I'm having problems because it joins a dozen
tables.  I'm aware of setting FetchModes in NHibernate; however, it
just seems like it's going to be difficult to recreate the results of
this query in OO format instead of tabular format.  Here's an example
query:

SELECT
   Book.ID,
   Book.Name,
   Author.Name,
   AuthorAddress.State,
   Publisher.Name,
   PublisherAddress.State
FROM
   Book
      INNER JOIN Author ON (Author.ID = Book.AuthorID)
      INNER JOIN Address AuthorAddress ON (AuthorAddress.ID =
Author.AddressID)
      INNER JOIN Publisher ON (Publisher.ID = Book.PublisherID)
      INNER JOIN Address PublisherAddress ON (PublisherAddress.ID =
Publisher.AddressID)

Now this is a mocked up example, but you can see the Joins go more
than one level deep.  After I figure in dynamic sorting and paging,
the Stored Proc yields the exact structure I want to show in my grid.
I'm having problems replicating this with NHibernate.  Any advice out
there?  Should I be taking a different approach?  I thought about
keeping a stored procedure and loading it to a simple DTO for display
in my grid, but there's domain logic I would love to include in the
grid, and I'd hate to replicate it.

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