Re: sort returned entities by related entity attribute
Re: sort returned entities by related entity attribute
- Subject: Re: sort returned entities by related entity attribute
- From: Johann Werner <email@hidden>
- Date: Sun, 6 Jul 2008 12:02:01 +0200
Hi Jeff,
of course your sort will fail as returnedEntity doesn't know anything
about the attribute sortKey. You have to put the complete key path
from returnedEntity to the attribute you want the list to be sorted
with:
EOSortOrdering sortBy = new
EOSortOrdering(returnedEntity.RELATION_TO_SUB_ENTITY_KEY + "." +
subEntity.SORT_KEY_KEY, EOSortOrdering.CompareDescending);
of if you are using Wonder as you noted you could make it with:
NSArray<EOSortOrdering> sortByArray =
returnedEntity
.RELATION_TO_SUB_ENTITY.append(subEntity.SORT_KEY).descs();
Have a look at ERXKey for all sorts of qualifier and sort ordering
methods.
jw
Am 06.07.2008 um 05:35 schrieb Jeff Schmitz:
Hello,
This is really hard to put down succinctly, so I'll try to do it
a couple different ways:
Is there an easy way to base the sort order of an array entities
returned on an attribute of an entity related to each of the
returned entities?
IOW:
startEntity to-many returnedEntity sorted by returnedEntity to-
one subEntity.sortKey.
Note that the returnedEntity owns, and propogates its primary key
to, the subEntity.
e.g. This was basically my first try (I'm using wonder), but since I
was applying a subEntity sort key on a returnedEntity array, it of
course choked.
EOSortOrdering[] sortBy = {
new EOSortOrdering(subEntity.SORT_KEY,
EOSortOrdering.CompareDescending)};
NSArray<EOSortOrdering> sortByArray = new NSArray<EOSortOrdering>(
sortBy); // Sort
NSArray<Entry> entities = this.returnedEntity(null,
sortByArray, false);
Thanks!
Jeff
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden