Created
September 28, 2011 20:46
-
-
Save Krizzzn/1249217 to your computer and use it in GitHub Desktop.
C#: EF Save Event Handler
This file contains hidden or 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(SaveOptions options) | |
{ | |
foreach (ObjectStateEntry entry in | |
ObjectStateManager.GetObjectStateEntries( | |
EntityState.Added | EntityState.Modified)) | |
{ | |
// Validate the objects in the Added and Modified state | |
// if the validation fails throw an exeption. | |
} | |
return base.SaveChanges(options); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment