Distinct Condition when fetching Entity Collection

Posts   
 
    
Kent
User
Posts: 1
Joined: 06-Apr-2005
# Posted on: 06-Apr-2005 21:22:08   

Hello, I'm wondering how do you pull off a simple distinct column when populating a entity collection? I.E. Select Distinct ColumnName From Table.

Any help would be appreciated, As you can tell I am a new user of GenPro.

Thanks, Kent

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 06-Apr-2005 21:42:34   

You should use a dynamic list with just one field. See for more details about dynamic lists, the TypedList/view documentation in the Using the generated code section.

Frans Bouma | Lead developer LLBLGen Pro
AtomicInternet avatar
Posts: 1
Joined: 26-May-2005
# Posted on: 26-May-2005 23:42:28   

I'm also having trouble selecting distinct items from a DB.

My DB is ID | LOAN | VENDORMESSAGE | STATUS | DATE

I want a list of all possible MESSAGES and STATUSES to populate dropdowns so a user can search based on the criteria. The possible values are constantly changing so I need to select distinct each time. I've looked at the "Creating dynamic lists" section of the help but nothing jumped out at me.

Do you have any sample code starting with creating the ResultsetFields definition all the way through fetching the list? (entire block of code)

Thanks for any help. I'm still getting used to the LLBLGen paradigm.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 27-May-2005 10:06:00   

This should get you started:


// selfservicing:

ResultsetFields fields = new ResultsetFields(1);
fields.DefineField(YourEntityFieldIndex.VendorMessage, 0, "VendorMessage");
TypedListDAO dao = new TypedListDao();
DataTable messages = new DataTable();
dao.GetMultiAsDataTable(fields, messages, 0, null, null, null, false, null, null, 0, 0);

I specify 'false' for allowDuplicates, so I get distinct messages.

Frans Bouma | Lead developer LLBLGen Pro
Banane avatar
Banane
User
Posts: 67
Joined: 01-Sep-2004
# Posted on: 29-Jun-2005 19:49:49   

Hi i'm doing that....and it does not insert DISTINCT in the SELECT

what I'm doing wrong?

tx


DataTable dynamicList = new DataTable("tb1");
TypedListDAO dao = new TypedListDAO();
        
ISortExpression sort = new SortExpression();
sort.Add(SortClauseFactory.Create(EPEObjectFieldIndex.EPEObjectID, SortOperator.Descending));

dao.GetMultiAsDataTable(fields, dynamicList, 500, sort, filter,relationsToUse,false,null, null, 0, 0);

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 29-Jun-2005 20:36:55   

That happens if one of the fields in the fields object is a distinct violating type, like image, text, blob/clob etc.

Frans Bouma | Lead developer LLBLGen Pro