Customizing Add and AddRange #728
-
Hi everyone, I want to customize logging for Add and AddRange separately in Audit.NET, as their logging logic will be different. Is there a way to differentiate audit logs between Add and AddRange? |
Beta Was this translation helpful? Give feedback.
Answered by
thepirat000
Feb 4, 2025
Replies: 1 comment 2 replies
-
do you mean List.AddRange? |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Internally,
DbSet.AddRange
invokes the same method asAdd
within aforeach
loop:Source: EF Core - InternalDbSet.cs (Line 567)
There is no way to determine whether an entity was added via
Add
orAddRange
.You could potentially implement your own
DbSet<T>
, but it’s not as simple as inheriting fromDbSet<T>
and adding custom logic:Related discussion on Stack Overflow.