Auto Increment Properties

Auto Increment Properties

Old forum URL:

abreu.bruno posted on Thursday, July 07, 2011

How can I get a value of an auto-increment column in the database and 
set on a property?

Here is my code:

protected override void DataPortal_Insert()


            using (AquariusEntities ae = new AquariusEntities())


                Model.Account account;


                account = new Model.Account


                    CreationDate = ReadProperty(CreationDateProperty),

                    Description = ReadProperty(DescriptionProperty),

                    Id = ReadProperty(IdProperty),

                    LastAccess = ReadProperty(LastAccessProperty),

                    Password = ReadProperty(PasswordProperty)





                SetProperty<Int32>(CodeProperty, account.Code);



But when I try to access the property from my object (account.Code), it is the default value.

abreu.bruno replied on Friday, July 08, 2011


tiago replied on Friday, July 08, 2011

Hi Bruno, Download the samples and give them uma boa mirada. I recommend PTracker; most if not all of the answers are there.

Marjon1 replied on Monday, July 11, 2011

The key thing to remember that you always get a new object back when calling save, so your call must look like:  obj = obj.Save()

Copyright (c) Marimer LLC