private static ProblemInfo ParseEntityExceptionError(Exception e)
{
var errors = e.GetType().GetProperty("EntityValidationErrors").GetValue(e ) as IEnumerable;
var errorMessage = new StringBuilder();
var dictionary = new Dictionary<string, string>();
foreach (var err1 in errors)
{
var validationErrors = err1.GetType().GetProperty("ValidationErrors").GetValue(err1) as IEnumerable;
foreach (var err2 in validationErrors)
{
var message = err2.GetType().GetProperty("ErrorMessage").GetValue(err2) as string;
var property = err2.GetType().GetProperty("PropertyName").GetValue(err2) as string;
dictionary.Add(property, message);
}
}
var problem = new ProblemInfo(ProblemType.EntityValidationError);
problem.InfoBlocks.Add("ValidationErrors", dictionary);
return problem;
}