我正在捕获DbEntityValidationException,并且想要填充包含所有错误的Dictionary。目前我正在做以下事情:将嵌套循环更改为Linq
foreach (var entity in errors)
{
foreach (var error in entity.ValidationErrors)
{
validationErrors.Add(entity.Entry.Entity.GetType().FullName + "." + error.PropertyName,
error.ErrorMessage)
}
}
是否有可能将上述循环转换为linq语句?
你的钥匙是指错误不是实体 – 2014-11-06 08:34:07
此外,你有因为使用绑定变量“错误”的初始集合冲突格兰名字笔误,应该是错误的 – Georg 2014-11-06 08:35:54
@ Selman22良好的捕获,修复它。 – flindeberg 2014-11-06 08:37:13