Table of Contents

Class AuditEntry

Namespace
KYS.EFCore.Library.DBContext.Partials
Assembly
KYS.EFCore.Library.dll

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

AuditAction

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

string

HasTemporaryProperties

Gets a value indicating whether the entry has properties that must be completed after saving.

public bool HasTemporaryProperties { get; }

Property Value

bool

KeyValues

Gets the primary key values of the entity, keyed by property name.

public Dictionary<string, object> KeyValues { get; }

Property Value

Dictionary<string, object>

NewValues

Gets the current property values (for insertions and updates), keyed by property name.

public Dictionary<string, object> NewValues { get; }

Property Value

Dictionary<string, object>

OldValues

Gets the original property values (for deletions and updates), keyed by property name.

public Dictionary<string, object> OldValues { get; }

Property Value

Dictionary<string, object>

TableName

Gets or sets the name of the audited entity (its CLR type name).

public string TableName { get; set; }

Property Value

string

TemporaryProperties

Gets the properties whose values are generated by the database and are only known after saving.

public List<PropertyEntry> TemporaryProperties { get; }

Property Value

List<PropertyEntry>

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

formatting FormattingHelper.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

ReferenceId is taken from the first entry of KeyValues.

Exceptions

InvalidOperationException

Action is Update and ColumnName has no matching entry in OldValues or NewValues.