I'm sorry if the title is not representative enough.
So in my case, I want to build a more dynamic search form. Previously my search form only support equal operator. Now I want it to support another operators (contains, greater than etc).
This is what my previous search form model looks like:
public class PersonQuery
{
[StringLength(100)]
public string FirstName { get; set; }
// the rest of the properties
}
And now the new query model is look like this:
public class AdvPersonQuery
{
[StringLength(100)]
public FilterField<string> FirstName { get; set; }
}
where FilterField:
public class FilterField<T>
{
// in this case I want the [StringLength(100)] attribute
// or any other data annotation that is put on property that use this class to be used here
public T Value { get; set; }
public OperatorTypes Operator { get; set; }
}
In this case I want the Value property data annotations refer to data annotations of property that use this class in the example above is FirstName property. So that when I put Value property of FirstName in View, the field will be validated based on the validation attribute defined on the FirstName property.