Thursday, 22 August 2013

ModelState create List string with Key + ErrorMessage. (LINQ)

ModelState create List string with Key + ErrorMessage. (LINQ)

I Want to obtain something like this:
' myKey: errorMessage '
Now i've a list with all the ModelState errors:
List<String> modelStateErrors2 = ModelState.Keys.SelectMany(key =>
this.ModelState[key].Errors).Select(x => x.ErrorMessage).ToList();
But need to add the key in the begin of the string.
It is possible?

No comments:

Post a Comment