Created
October 23, 2011 19:30
-
-
Save motowilliams/1307763 to your computer and use it in GitHub Desktop.
Extension-Methods-Improving-the-quality-of-Life
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 static class ModelStateExtensions | |
{ | |
public static void AddModelErrors(this ModelStateDictionary values, IEnumerable<ValidationResult> validationResults) | |
{ | |
foreach (var validationResult in validationResults) | |
values.AddModelError(validationResult.MemberNames.FirstOrDefault(), validationResult.ErrorMessage); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment