0

I'm trying to set up some custom validation methods that use the System.ComponentModel.DataAnnotations. I have written a few generic methods to use for validation. Here is the one where the problem occurs:

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);
    }

I have an error on the 'ValidationAttribute' type saying that it could not be found. I have the using statement for DataAnnotations. Any ideas?

c.dunlap
  • 600
  • 1
  • 11
  • 28
  • try looking at the previous stackoverflow posting I think others have had the issue / similar question http://stackoverflow.com/questions/2649581/custom-validationattribute-test-against-whole-model – MethodMan Mar 18 '13 at 21:51

1 Answers1

0

Nevermind! I figured it out. Apparently the using statement is not enough. I also had to add the project reference to the package.

c.dunlap
  • 600
  • 1
  • 11
  • 28