Skip to content

Add automatic Auditing capability for different table #94

@MitarNikolic

Description

@MitarNikolic

My issue here is that if I am trying to create triggers for auditing, I have to specify each column individually or execute a raw SQL query that looks something like this:

INSERT INTO auditing (SELECT * FROM source WHERE source.something = something)

The issue with this is that the auditing table has to look exactly the same as the source table. But that only allows insertion of one entry per element if you want to have the ID as a primary key. I would want to have an "AuditId" and a "SourceId" but that is not possible when using this query!

So I think it would be cool to have a method that you can use similarly to methods like Insert, Update, Upsert and so on called Audit

Would be cool if this could automatically map the columns with the same name and then you would have the ability to attach another method or perhaps a function argument that maps the rest of the values.

Usage:

 modelBuilder.Entity<Source>()
     .BeforeUpdate(trigger => trigger
         .Action(action => action
           //Does the automatic mapping
            .Audit<Source, Audit>()
            .HandleUnmapped( (source, audit) => audit.Action = "Update" )));

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions