DEV Community

loading...

Discussion on: Use Action Filters to cut down your context.SaveChanges calls

Collapse
jonhilt profile image
Jon Hilton Author

Hi James, yep you've got it.

This essentially gives you a transaction per web request, so you can be confident the operation either worked or it didn't (and you won't get into a "half n half" state where some things are persisted to the database but others aren't).

By default ASP.NET Core will commit everything in one transaction when you call SaveChanges, so every modified entity will persisted in one go :-)

Collapse
jamesmh profile image
James Hickey

Nice - did not know that! Thanks for the extra details about the transaction.

This tactic has lots of other interesting benefits 👌