本文介绍了在即时窗口中获取EntityValidationErrors的列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在VS 2012中发生中断时,如何在即时窗口中获取错误列表
How can I get a list of errors in the immediate window when this breaks in VS 2012
在不进行代码修改的情况下,似乎不是显示它们的简单方法像这样循环遍历它们:
there doesn't appear to be a simple way of displaying them without creating some code modifications to loop through them like so:
foreach (var failure in ex.EntityValidationErrors)
{
string validationErrors="";
foreach (var error in failure.ValidationErrors)
{
validationErrors+=error.PropertyName+" "+error.ErrorMessage;
}
}
推荐答案
((System.Data.Entity.Validation.DbEntityValidationException)$exception)
在监视窗口中,您可以访问异常实例。您可以从那里检查错误集合。
in the Watch window will give you access to the exception instance. You can check out the error collection from there.
我将其保留在监视列表中,因此如果遇到该异常,我可以刷新。
I keep that available in my Watch list so I can just refresh if I run into that exception.
这篇关于在即时窗口中获取EntityValidationErrors的列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!