Created
March 28, 2012 20:30
-
-
Save jpoehls/2230255 to your computer and use it in GitHub Desktop.
Get dictionary of errors from ModelState in ASP.NET MVC
This file contains hidden or 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
var errorList = ModelState | |
.Where(x => x.Value.Errors.Count > 0) | |
.ToDictionary( | |
kvp => kvp.Key, | |
kvp => kvp.Value.Errors.Select(e => e.ErrorMessage).ToArray() | |
); |
@jpoehls I got you but why am I not able to see KeyValuePairs directly in the breakpoint. They are coming in the Values and Keys. This thing is confusing me. or will we loop according to things which is coming in "Result View" ?
You may be able to expand the Results View
or Non-Public members
to explore the pairs. I'm afraid I can't offer more specific help.
@jpoehls Thanks.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@jpoehls I got you but why am I not able to see KeyValuePairs directly in the breakpoint. They are coming in the Values and Keys. This thing is confusing me. or will we loop according to things which is coming in "Result View" ?
