Re: DistinctRows
Re: DistinctRows
- Subject: Re: DistinctRows
- From: Chuck Hill <email@hidden>
- Date: Mon, 03 Mar 2003 15:16:18 -0800
- Organization: Global Village Consulting, Inc.
There are several ways to accomplish this, including raw SQL and fetch specs set
to fetch distinct rows. But in the interests of making minimal changes...
Jonathan Fleming wrote:
If I use the code below to create a list of the EOModel attribute named
navPageName, how can I then be sure to list only distinct rows? The code
is used in a popup list, but instead of:
Home
Home
Home
Reference
Reference
Terms
I want to get:
Home
Reference
Terms
No Fetch spec is used to create the list.
Here's the list code:
/** @TypeInfo TbNavPage */
public NSArray sortedNavPageNames() {
// create new navPage list
EOEditingContext ec = this.session().defaultEditingContext();
NSMutableArray sortedNavPageNameList = new
NSMutableArray(EOUtilities.objectsForEntityNamed(ec, "TbNavPage"));
Replace above line with:
NSArray pageNameList = EOUtilities.objectsForEntityNamed(ec, "TbNavPage");
NSSet uniquePageNameList = new NSSet(pageNameList);
NSMutableArray sortedNavPageNameList = new
NSMutableArray(uniquePageNameList.allObjects());
Chuck
// Sort ordering created here to sort unsorted clients
EOSortOrdering navPageNameSortOrdering =
EOSortOrdering.sortOrderingWithKey("navPageName",
EOSortOrdering.CompareAscending);
NSArray sortOrderings =
new NSArray( new Object[]{navPageNameSortOrdering});
// Sort away!
EOSortOrdering.sortArrayUsingKeyOrderArray(sortedNavPageNameList,
sortOrderings );
return sortedNavPageNameList;
}
Advanced Thanks
Jonathan
--
Chuck Hill email@hidden
Global Village Consulting Inc. http://www.global-village.net
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.
References: | |
| >DistinctRows (From: "Jonathan Fleming" <email@hidden>) |