Distinct records by someEntityCollection.getMulti() ?

Posts   
 
    
ES
User
Posts: 2
Joined: 21-Feb-2007
# Posted on: 21-Feb-2007 16:27:26   

Hi there, we're looking for a way to fetch distinct records only from a data table. This is what we're trying:

 AvActivityCollection activities = new AvActivityCollection();          
 activities.GetMulti(null); //fetch all activities

This fetches all activities, but we'd like to only fetch activities with distinct values in a certain column. Is there any way to achieve this?

The sql we would have written for this is:

select distinct(act) from AvActivities;

Regards, ES

Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 21-Feb-2007 16:57:41   

select distinct(act) from AvActivities;

I understand from the above query that you want to fetch distinct values of the "act" column from the AvActivities table.

Well you can just use a Dynamin List (which is a DataTable). While passing a flag for the allowDuplicates paramter. Examples can be found here: http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=8942

ES
User
Posts: 2
Joined: 21-Feb-2007
# Posted on: 21-Feb-2007 17:19:50   

The link you posted doesn't seem to work?

regards, ES

Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 21-Feb-2007 17:35:30   

Strange, it works here, Anyway, here is the adapter example posted there:

DataAccessAdapter adapter = new DataAccessAdapter();
ResultsetFields fields = new ResultsetFields(1);
fields.DefineField(OrderFields.ShipCountry, 0);

DataTable dynamicList = new DataTable();
adapter.FetchTypedList(fields, dynamicList, null, false); // false here for the Distinict

For SelfServicing use the equivilant GetMultiAsDataTable method.

TypedListDAO dao = new TypedListDAO();
dao.GetMultiAsDataTable(....)