Efficient entity updating with an auto incremeted primary key

Posts   
 
    
cjmos
User
Posts: 15
Joined: 04-May-2007
# Posted on: 23-Jul-2007 12:31:09   

Hi all,

I'm trying to implement the more efficient method of updating my entities

CartEntity cart = new CartEntity();
cart.Id = cartId;
cart.IsNew = fasle;

rather than

CartEntity cart = new CartEntity(cartId);

The problem is that my primary key is an auto-incremented int field, so when I try and set the id of the cart, I get the error.

SD.LLBLGen.Pro.ORMSupportClasses.ORMFieldIsReadonlyException: The field 'Id' is read-only and can't be changed.

Obviously I understand why i get this error but is there any other way to update an entity without first retrieving it from the db?

Thanks,

DvK
User
Posts: 323
Joined: 22-Mar-2006
# Posted on: 23-Jul-2007 13:28:26   

I guess you're using Selfservicing here...?! You can set the PK-value though, use entity.Fields(x).ForcedCurrentValueWrite.

Kind regards, Danny

cjmos
User
Posts: 15
Joined: 04-May-2007
# Posted on: 23-Jul-2007 13:33:16   

I just noticed it's written right there in the manual, sorry for wasting time.

Thanks for the response.