How to use PredicateExpression ??

Posts   
 
    
Posts: 3
Joined: 19-May-2005
# Posted on: 24-May-2006 10:42:03   

Ok I being a little dumb here but ....

I've created an entity class, Self Servicing, to test from a single Oracle table, but I can't work out how to select a record or records based on a column other than the PK.

The table in question has a unique index on a code column that I want to use, but I just can't seem to work out how to apply the PredicateExpression created to the entity.

            
Dim oFilter As PredicateExpression = New PredicateExpression()

oFilter.Add(PredicateFactory.CompareValue(UserxFieldIndex.UseCode, ComparisonOperator.Equal, txtUserName))

Also, I was under the impression from the doco that I should have access to unique constraint methods, i.e. FetchUsingUCUseCode, but this hasn't been created.

Any and all help welcome

Ta

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 24-May-2006 14:31:06   

Filters may return more than one entity, that's why they are applied when fetching EntityCollections not single entities. Please refer to GetMulti() method in the LLBLGen Pro reference manual.

Posts: 3
Joined: 19-May-2005
# Posted on: 25-May-2006 01:18:51   

Fair enough, but how then can you select a record from an entity class on a unique column when the UC access methods aren't generated?

What is the trigger that tells LLBL to generate these methods when using Oracle?

This is the script for the table


create table USERX
(
  ROWVERSION        INTEGER not null,
  USE_ID                  INTEGER not null,
  USE_CODE          VARCHAR2(30) not null,
  LONG_DESC       VARCHAR2(30) not null,
  GRP_ID                 INTEGER not null,
  ACTIVE_FLAG       VARCHAR2(6) default 'YES' not null,
  EMAIL                VARCHAR2(50),
  AGG_ID                 NUMBER(22),
  MGR_ID                 NUMBER(22),
  DEPARTMENT         CHAR(3) default 'MED' not null,
  DEFAULT_APPROVER_USE_ID NUMBER(22)
)

alter table USERX add constraint IDX_USE_PK primary key (USE_ID) using index ;

create unique index IDX_USE_AK on USERX (USE_CODE)

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 25-May-2006 06:42:14   

please try the following statement to create a unique constraint:


alter table USERX add constraint USERX_unique unique(USE_CODE);