Database

From Bitnami MediaWiki
Revision as of 20:39, 3 October 2023 by User (talk | contribs) (Created page with "<strong>See also</strong> the Optimistic Concurrency Control section. <strong>Audit fields (database).</strong> Generally, most tables should have the following audit files: <pre>created_on datetime2(7) NULL ,created_by varchar(100) NULL, ,updated_on datetime2(7) NULL, ,updated_by varchar(100) NULL</pre> 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 pa...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

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