Created
March 19, 2013 23:29
-
-
Save ctolkien/5201102 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public override int SaveChanges() | |
{ | |
//this goes through and updates the created on / modified on dates. | |
this.ChangeTracker.Entries<BaseModel>().ForEach(x => | |
{ | |
if (x.State == System.Data.EntityState.Added) | |
{ | |
x.Entity.CreatedOn = DateTime.UtcNow; | |
} | |
x.Entity.ModifiedOn = DateTime.UtcNow; | |
}); | |
return base.SaveChanges(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment