Class AuditEntry
In-memory representation of the changes made to a single tracked entity, collected by SaveChangesWithAuditAsync(Guid?, Formatting?) and converted to an ActionLog through ToActionLog(Formatting?).
public class AuditEntry
- Inheritance
-
AuditEntry
- Inherited Members
Properties
Action
Gets or sets the kind of change made to the entity.
public AuditAction Action { get; set; }
Property Value
ColumnName
Gets or sets the name of the changed property for an Update.
When several properties change, only the last one processed is kept.
public string ColumnName { get; set; }
Property Value
HasTemporaryProperties
Gets a value indicating whether the entry has properties that must be completed after saving.
public bool HasTemporaryProperties { get; }
Property Value
KeyValues
Gets the primary key values of the entity, keyed by property name.
public Dictionary<string, object> KeyValues { get; }
Property Value
NewValues
Gets the current property values (for insertions and updates), keyed by property name.
public Dictionary<string, object> NewValues { get; }
Property Value
OldValues
Gets the original property values (for deletions and updates), keyed by property name.
public Dictionary<string, object> OldValues { get; }
Property Value
TableName
Gets or sets the name of the audited entity (its CLR type name).
public string TableName { get; set; }
Property Value
TemporaryProperties
Gets the properties whose values are generated by the database and are only known after saving.
public List<PropertyEntry> TemporaryProperties { get; }
Property Value
UserId
Gets or sets the identifier of the user who made the change.
public Guid? UserId { get; set; }
Property Value
- Guid?
Methods
ToActionLog(Formatting?)
Converts this audit entry to an ActionLog.
public Result<ActionLog> ToActionLog(FormattingHelper.Formatting? formatting = null)
Parameters
formattingFormattingHelper.Formatting?The naming convention applied to ReferenceTable and ColumnName. When it is KYS.Library.Helpers.FormattingHelper.Formatting.SnakeCase, the keys of RecordValue are converted to snake_case as well. null keeps the original names.
Returns
- Result<ActionLog>
A successful CSharpFunctionalExtensions.Result<T> containing the ActionLog, or a failed result with an error message when the table or column name could not be formatted.
Remarks
- Insert: RecordValue holds the key and new values as JSON.
- Update: ColumnOldValue and ColumnNewValue hold the values of ColumnName.
- Delete: RecordValue holds the key and original values as JSON.
Exceptions
- InvalidOperationException
Action is Update and ColumnName has no matching entry in OldValues or NewValues.