0

System.ComponentModel.DataAnnotations を使用するいくつかのカスタム検証メソッドを設定しようとしています。検証に使用する一般的なメソッドをいくつか作成しました。問題が発生する場所は次のとおりです。

private void SetValidationAttributeErrors<TEntity>(TEntity item, List<string> errors)
    {
        var result = from prop in TypeDescriptor.GetProperties(item).Cast<PropertyDescriptor>()
                     from attribute in prop.Attributes.OfType<ValidationAttribute>()
                     where !attribute.IsValid(prop.GetValue(item))
                     select attribute.FormatErrorMessage(string.Empty);
    }

「ValidationAttribute」タイプに、見つからないというエラーがあります。DataAnnotations の using ステートメントがあります。何か案は?

4

1 に答える 1

0

どうでも!私はそれを考え出した。どうやら using ステートメントでは不十分です。また、プロジェクト参照をパッケージに追加する必要がありました。

于 2013-03-18T22:20:45.260 に答える