Hi edalzell, three things come to my head:
- You could write some custom code at the entity initialization routine:
namespace Northwind.EntityClasses
{
public partial class CustomerEntity
{
protected override void OnInitialized()
{
if (this.IsNew) {
this.CreatedDate = DateTime.Now();
}
base.OnInitialized();
}
}
}
- Use Auditors. In this case, if you want to store the creation date, an auditor fit there.
public class GeneralAuditor : AuditorBase
{
public override void AuditInsertOfNewEntity(IEntityCore entity)
{
((SomeEntity) entity).CreationDate = DateTime.Now();
}
...
}
(for more info about Auditing, see LLBLGenPro Help -> Using the generated code -> Setting up and using Auditing)
- You also could use Validators:
public class CustomerValidator : ValidatorBase
{
public override void ValidateEntityBeforeSave( IEntityCore involvedEntity )
{
// .... some validations
// set the creation date
((SomeEntity) involvedEntity).CreationDate = DateTime.Now();
base.ValidateEntityBeforeSave( involvedEntity );
}
}
(for more info about Validation, see LLBLGenPro Help -> Using the generated code -> Validating per field or per entity
As you are setting a CreationDate field (in your example), I would recommend go for Auditing. You only need to set that once, then every time you save a new SomeEntity the CreationDate would be filled.
Hope helpful