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

AuditableEntityInterceptor only processing 'parent' and ignore 'child' entities? #1304

Open
mrhighstone opened this issue Feb 27, 2025 · 2 comments

Comments

@mrhighstone
Copy link

Is it correct that the AuditableEntityInterceptor only processes 'parent' entities and ignore 'child' entities?

I'm having a parent-child relation in my application, lets say an Order holding OrderLineItems. After adding items to the list and saving the Order, the AuditableEntityInterceptor correctly updates the created and updated properties of the Order but ignores the OrderLineItems.

Is this as intended? And if so, how to also update the auditable fields of an OrderLineItem when the Order is saved?

@DennisJansenDev
Copy link

Is your OrderLineItem class also inheriting from BaseAuditableEntity? And are they being tracked by the DbContext?

@mrhighstone
Copy link
Author

mrhighstone commented Feb 27, 2025

Yes, it is inheriting from BaseAuditableEntity.

But it is clearly not being tracked by the DbContext. It is created in the database, however.

Effectively, all that that command handler is doing, after fetching the Order and instantiating the OrderLineItem is

order.OrderLineItems.Add(lineItem)

Followed by

 _context.SaveChangesAsync();

And I was hoping this was enough to get the job done, and not having the command handler thinking about entities being tracked or not.

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

2 participants