amantinband / clean-architecture

The ultimate clean architecture template for .NET applications 💪
MIT License
1.4k stars 221 forks source link

Refactoring "SaveChangesAsync" - Popping DomainEvents #4

Closed amirhessampourhossein closed 7 months ago

amirhessampourhossein commented 7 months ago

Hello @amantinband Thank you for responding to my issue (#3) ❤

I have noticed the following piece of code in your "SaveChangesAsync" method 👇

var domainEvents = ChangeTracker.Entries<Entity>()
   .Select(entry => entry.Entity.PopDomainEvents())
   .SelectMany(x => x)
   .ToList();

couldn't we use the following piece of code instead ? 👇

var domainEvents = ChangeTracker.Entries<Entity>()
   .SelectMany(entry => entry.Entity.PopDomainEvents())
   .ToList();
amantinband commented 7 months ago

Yep that's better. Changed 🤙