I have the verification attribute set, where I need to get into the database in order to perform the verification. I tried to configure the property attachment in the same way as in other places in the project, but it does not work. What step am I missing?
public class ApplicationIDValidAttribute : ValidationAttribute
{
[Inject]
protected IRepository<MyType> MyRepo;
public override bool IsValid(object value)
{
if (value == null)
return true;
int id;
if (!Int32.TryParse(value.ToString(), out id))
return false;
var obj= MyRepo.LoadById(id);
return (obj!= null);
}
One more note: I have a Ninject kernel configured to enter non-public properties, so I don't think this is a problem. I am using Ninject 2, MVC 2 and the MVC 2 version for Ninject.Web.MVC.
Thank!
source
share