Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add automatic Auditing capability for different table #94

Open
MitarNikolic opened this issue Dec 8, 2023 · 0 comments
Open

Add automatic Auditing capability for different table #94

MitarNikolic opened this issue Dec 8, 2023 · 0 comments

Comments

@MitarNikolic
Copy link

MitarNikolic commented Dec 8, 2023

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" )));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant