-
-
Save jpoehls/2230255 to your computer and use it in GitHub Desktop.
var errorList = ModelState | |
.Where(x => x.Value.Errors.Count > 0) | |
.ToDictionary( | |
kvp => kvp.Key, | |
kvp => kvp.Value.Errors.Select(e => e.ErrorMessage).ToArray() | |
); |
thanks
Thanks a lot, useful
Thank you. This was helpful.
Thanks a lot!
Still saving lives. Thanks
Thanks!
UwU
@jpoehls please can you explain how the code is working ? because I am seeing "Values" and "Keys" in the model state. What exactly "x" is referring to in the code ?
@jpoehls please can you explain how the code is working ? because I am seeing "Values" and "Keys" in the model state. What exactly "x" is referring to in the code ?
“x” is the KeyValuePair<> in the ModelStateDictionary. You can read the docs on that Type here: https://learn.microsoft.com/en-us/dotnet/api/system.web.mvc.modelstatedictionary?view=aspnet-mvc-5.2
@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" ?
@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.
fdasfasfsa