Upate - the PK field is read-only

Posts   
 
    
nevernet
User
Posts: 67
Joined: 01-Feb-2010
# Posted on: 03-Feb-2010 09:36:42   

the example from documentation version 2.6

CustomerEntity customer = new CustomerEntity();
customer.CustomerID="CHOPS";
customer.IsNew=false;
customer.Phone = "(605)555-4321";
customer.Save();

my code :

SalutationEntity salu = new SalutationEntity();
            salu.SalutationId = 40;
            salu.IsNew = false;
            salu.Name = "hello";
            salu.MappingName = "haha";
            
            //doesn't update Sex filed
            //salu.Sex = "0";

            salu.Save();

but i got an error : The property "SalutationId " is read only.

Note: SalutationId is Primary Key filed.

thank you

Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 03-Feb-2010 10:02:09   

Is it an Identity field/ auto-geneated t the database side?

nevernet
User
Posts: 67
Joined: 01-Feb-2010
# Posted on: 03-Feb-2010 10:04:56   

Walaa wrote:

Is it an Identity field/ auto-geneated t the database side?

Yes

Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 03-Feb-2010 10:12:33   

That's why it's read-Only. Why do you want to set it? If it's gonna be set at the database side.

(EDIT) If you want to update an existing entity, please do the following.

            SalutationEntity salu = new SalutationEntity(40);
            salu.IsNew = false;
            salu.Name = "hello";
            salu.MappingName = "haha";
            salu.Save();
nevernet
User
Posts: 67
Joined: 01-Feb-2010
# Posted on: 03-Feb-2010 10:14:40   

actually ,i dont know i just do practice with example in documentation

then i found the problem ,and asked at here.

Thank you for your explaination.