Skip to content

Instantly share code, notes, and snippets.

@jpoehls
Created March 28, 2012 20:30
Show Gist options
  • Save jpoehls/2230255 to your computer and use it in GitHub Desktop.
Save jpoehls/2230255 to your computer and use it in GitHub Desktop.
Get dictionary of errors from ModelState in ASP.NET MVC
var errorList = ModelState
.Where(x => x.Value.Errors.Count > 0)
.ToDictionary(
kvp => kvp.Key,
kvp => kvp.Value.Errors.Select(e => e.ErrorMessage).ToArray()
);
@enggomarpu
Copy link

@jpoehls Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment