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(); } }
No comments:
Post a Comment