tabs ↹ over ␣ ␣ ␣ spaces

by Jiří {x2} Činčura

SaveChanges is virtual in EF4

30 Jun 2009 Entity Framework

I don’t know whether I just noticed this too late, but the SaveChanges method in upcoming EF4 is virtual. This is a great small change.

You can generate (if you’re using T4 templates for generating) your own SaveChanges method and do some work there. Well, before actions can be done using SavingChanges event, i.e. validation like in this example. But for after actions, there’s no SavedChanges event (neither in EF4). Hence adding some code into this method is very handy. For example logging actions performed is super easy.

This small change opens up new ways of thinking about SaveChanges usage.

The method also have new SaveOptions parameter. As it’s enum we can expect adding more options in future versions.