Read only for update

Posts   
 
    
Ian avatar
Ian
User
Posts: 511
Joined: 01-Apr-2005
# Posted on: 19-Oct-2005 16:21:51   

Hi,

Is it possible to have a field on an entity which is not written to on an update but which is written to on an insert?

For example, a user entity might have a password field but you don't want to write to this when a user is updating their details because changing the password would be done on a different page.

So, I want to create a new User object which will represent an existing user and call save on it and not have to specify the current password value - its just left uneffected in the DB. But when I create a new User object for a new user, I need to specify the password and it will go in with the insert.

Cheers, I.

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 19-Oct-2005 16:24:51   

And what will you do when the user want to change his password in the other page? Wouldn't that be an Update?!!

Ian avatar
Ian
User
Posts: 511
Joined: 01-Apr-2005
# Posted on: 19-Oct-2005 16:52:38   

In fact it behaves the way that I want anyway. I just didn't set the entity to IsNew = false;

Paul.Lewis
User
Posts: 147
Joined: 22-Aug-2005
# Posted on: 20-Oct-2005 04:47:30   

Ian wrote:

In fact it behaves the way that I want anyway. I just didn't set the entity to IsNew = false;

Ian,

You can also set UserEntity.Password.IsChanged = false to ensure the password isn't updated even if other attributes are.

IsNew = false only ensures the update. By itself it doesn't ensure the password value isn't persisted to the DB.