Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8552297
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T14:23:40+00:00 2026-06-11T14:23:40+00:00

Been trying to get the following working using nhibernate HQL or QueryOver. I am

  • 0

Been trying to get the following working using nhibernate HQL or QueryOver. I am trying to get a sorted DISTINCT list of the entity organisation while sorting on joined tables and using paging.
Entities are (shortened version):

Organisation

 OrganisationId
 Name
 StatusId
 SubstatusId

Address

 AddressId
 OrganisationId
 City
 CountryId

ListItem

 ListItemId
 Name

StatusId, SubstatusId and CountryId are foreign keys to ListItemId
ListItemId is a list of user entered options.
There can be more than one address for each organisation

To sort on Organisation.Address[x].Country.Name I need to include this in the select, but obviously then I dont get distinct organisations rather distinct organisations for a particular address.

I cant then get this into the nHibernate entity as it has the additional Country.Name field.

Also I cant run another distinct over the initial results as im using .SetFirstResult and .SetMaxResults to do SQL Paging.
If I only want 10 rows, then I initially get 10 rows of distinct (organisation + country name).
When i run another distinct over this will get reduced if an organisation has more than address.

Any ideas how to get a distinct paged list of organisations while sorting on Address.Name, Status.Name, SubStatus.Name

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T14:23:41+00:00Added an answer on June 11, 2026 at 2:23 pm

    You could do it with 2 selects and a bit of linq:

    1. Do your projection selecting Organisation.Id, Address.Name, Status.Name, SubStatus.Name, ordering them appropriately and paging the results (well you just need to select Organisation.Id)

    2. Do another query to load the organisations by the Id’s in the previous projection

    3. Combine the queries to order the list of organisations by their order in the first select

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been trying to get this working for a while now and am just
Ive been trying to get an example Web Service working using SpringWS and Tomcat5.5
I've been trying for a while to get a ModelResource or a View working
I'm stuck trying to get multiple textures working in OpenGL using Haskell. I've been
I've been trying for about two hours to get the following code stored in
Been trying to get this up and running for a while now. Basically i
I've been trying to get something working in a windows 8 metro style application,
I've been trying to get styling working on site uncookedblog.com for hours now. I
I have been trying to get a handle on using MVC 4.0 with EF
I've been trying to get the camera section on my app working for about

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.