How do I retrieve the Primary Key value of a newly added entity...

Posts   
 
    
JayMan
User
Posts: 9
Joined: 02-May-2006
# Posted on: 03-May-2006 15:59:27   

Hi, How do I retrieve the Primary Key (which is autoincrementing) of a newly added entity?

This is what I am presuming:

adapter.SaveEntity(addressentity,true); // Refetchaftersave is set to true

// Here I expect the AddressID to be populated by the newly generated ID return addressentity.AddressId;

What am I doing wrong?

Any help will be greatly appreciated. thanks, Jayman

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 03-May-2006 16:12:55   

The PK should be returned in the Entity to save, even without using the refetch boolean.

In the LLBLGen Pro Designer, do you find the AddressID having IsPK = true(in the fields grid), and Is Identity / Sequence field is checked?

JayMan
User
Posts: 9
Joined: 02-May-2006
# Posted on: 03-May-2006 16:24:11   

Thanks Walaa. I forgot to regenerate the classes after setting the field as an autoincrementing field. Thanks, Jay