Checking unique keys

Posts   
 
    
Gareth
User
Posts: 24
Joined: 09-Apr-2004
# Posted on: 09-Apr-2004 23:36:20   

Hi,

I may have missed it, but is there away to check unique keys before the entity is saved?

For example, my UserEntity has two unique fields username and e-mail address (as well as the userID), before saving I need to check that these do not already exist in another record.

I know how I would normally do this, but does LLBLGen pro have any methods that could help?

Many thanks,

Gareth

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39612
Joined: 17-Aug-2003
# Posted on: 09-Apr-2004 23:43:58   

No sorry, no special methods to check this other than what you probably also would use: do a select on the value, if available, use another one.

It's an old, generic problem: right after you've checked if a value is present, some other user might save that value, so your save will fail.

Frans Bouma | Lead developer LLBLGen Pro
Gareth
User
Posts: 24
Joined: 09-Apr-2004
# Posted on: 10-Apr-2004 00:11:49   

Thanks, So it would definity be worth using a transaction this!