// private static string GetMessage(DbEntityValidationException ex) // { // var errors = new StringBuilder(); // errors.AppendLine(); //#if DEBUG // errors.AppendLine($"[{ex.GetType().Name}]"); //#endif // foreach (var error in ex.EntityValidationErrors) // { // var entity = error.Entry.Entity; // if (entity == null) continue; // var entityName = GetEntityName(entity); // errors.AppendLine($"{entityName}:"); // errors.AppendLine(); // foreach (var validation in error.ValidationErrors) // { // var propertyName = validation.PropertyName; // var entityType = error.Entry.Entity.GetType(); // var propInfo = entityType.GetProperty(propertyName); // var attributes = propInfo?.GetCustomAttributes(typeof(DisplayAttribute), false); // var displayAttribute = attributes?.Length > 0 ? attributes[0] as DisplayAttribute : null; // propertyName = displayAttribute?.Name ?? propertyName; // if (displayAttribute?.ResourceType != null) // { // var resourceManager = new ResourceManager(displayAttribute.ResourceType); // propertyName = resourceManager.GetString(propertyName) ?? propertyName; // } // errors.AppendLine($"{propertyName}: {validation.ErrorMessage}"); // } // } // return errors.ToString(); // } private static string GetMessage(DBConcurrencyException ex) { var errors = new StringBuilder(); errors.AppendLine(); #if DEBUG errors.AppendLine($"[{ex.GetType().Name}]"); #endif return(errors.ToString()); }