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)
};
ae.AddToAccount(account);
ae.SaveChanges();
SetProperty<Int32>(CodeProperty, account.Code);
}
}
But when I try to access the property from my object (account.Code), it is the default value.
??
Hi Bruno, Download the samples and give them uma boa mirada. I recommend PTracker; most if not all of the answers are there.
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