I wrote the following function to determine if an Entity has errors.
The part where I test a field for IDataErrorInfo is always null. Is there a more correct way to test if a field has IDataErrorInfo info?
public class EntityHasError
{
public static bool HasErrors(EntityBase Entity)
{
IDataErrorInfo err = Entity as IDataErrorInfo;
if (err != null)
if (err.Error != "")
return true;
for (int x = 0; x < Entity.Fields.Count - 1; x++)
{
** IDataErrorInfo field = Entity.Fields[x] as IDataErrorInfo;
if (field != null)
if(field.Error!="")
return true;**
}
return false;
}
}