Database
See also the Optimistic Concurrency Control section.
Audit fields (database). Generally, most tables should have the following audit files:
created_on datetime2(7) NULL ,created_by varchar(100) NULL, ,updated_on datetime2(7) NULL, ,updated_by varchar(100) NULL
Audit fields (C# code). In the Novus.Model.Entity.PartialEntities folder, create a partial class for the entity and implement the AuditFields interface e.g. public partial class Foo : AuditFields In the C# code, set the fields like this: entity.CreatedBy = GetUserId(); entity.CreatedOn = DateTime.UtcNow; UTC is not used since this complicates the C# code and SQL code where the time has to be converted to current timezone. Audit fields (BaseService helper method). With the entity implementing the AuditFields interface, call the SetAuditFields(dbContext, entity) for updates. For new entities, call SetAuditFields(dbContext, entity, true) by passing in true so that the CreatedOn and CreatedBy properties are also set.
Return to Programming Guide