public static class ExtensionMethods { public static ListFlattenErrors(this DbContext dbContext) { return dbContext .GetValidationErrors() .SelectMany(e => e.ValidationErrors .Select(ve => string.Format("Entity: [{0}], Property: [{1}], Error: [{2}].", ObjectContext.GetObjectType(e.Entry.Entity.GetType()).Name, ve.PropertyName, ve.ErrorMessage) )) .ToList(); } }
Keeping track of interesting places I put my feet on in the software development world.
Search This Blog
Sunday, August 30, 2015
Extension Method to Flatten Entity Framework Validations Errors - providing Entity, Property and Error message
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment