1

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


I assume you are talking about an iOS application. So, you have to turn the location services option from Xcode also, otherwise the webview will try itself as your issue. You can turn it on by changing the EnableLocation to true from Cordova.plist at the resources.

4

1 に答える 1

0

2つの選択と少しのlinqでそれを行うことができます:

  1. Organization.Id、Address.Name、Status.Name、SubStatus.Name を選択してプロジェクションを実行し、それらを適切に並べ替え、結果をページングします (Organisation.Id を選択するだけです)。

  2. 別のクエリを実行して、前のプロジェクションの ID で組織を読み込みます

  3. クエリを組み合わせて、最初の選択での順序で組織のリストを並べ替えます

于 2012-09-20T08:39:16.527 に答える