POCO和验证应用程序块错误

时间:2012-05-16 17:31:31

标签: .net poco

创建此对象后

ClassName obj = new ClassName
{
  Currency = "eur",
  DateStart = DateTime.Now.AddDays(-1),
  DateEnd = DateTime.Now.AddDays(-1)
};

并尝试验证它

var validationResults = Validation.Validate<ClassName>(obj);

我看到了这个错误,我不知道在哪里寻找并解决这个问题:

An unhandled exception of type 'System.ArgumentException' occurred in
Microsoft.Practices.EnterpriseLibrary.Validation.dll

Additional information: Object must be of type Int32.

感谢任何帮助。

感谢。

修改

这似乎是问题所在:

[RangeValidator(0f, RangeBoundaryType.Inclusive, 0f, RangeBoundaryType.Ignore, MessageTemplate = "...")]
public virtual double Price
{
    get;
    set;
}

1 个答案:

答案 0 :(得分:0)

您必须使用ClassName属性修饰Validator的某些字段或属性。我假设某些属性要么不适用,要么你错过了一些参数......

相关问题