I'm using adapter model, I want to set default value for some properties (such as created date) of the newly created entity. I implement this in InitClassEmpty(), it works fine for new entities, and default value assigned can be saved to database too.
However, those properties with default value assigned are flagged as changed, when I fetch existing entities from database, those properties is not set to the value read from database, but assigned default value. For example, created date is updated everytime I fetch the entities, I cannot get the correct value from database.
private void InitClassEmpty(ItemValidator validator, IEntityFields2 fields)
{
InitClassMembers();
base.Fields = fields;
base.IsNew=true;
base.Validator = validator;
// __LLBLGENPRO_USER_CODE_REGION_START InitClassEmpty
CreatedDate = DateTime.Now;
// __LLBLGENPRO_USER_CODE_REGION_END
}
Am I coding in wrong ways to set default value?
Thank you very much!