RangeAttribute and Nullable<int> issue
Posted: Fri 28 Jun 2013 12:30
Hello,
I have propery witch is Int and can be null. I set min and max as range. When I generate class DataAnnotation RangeAttribute is added to property. Attribute use constructor RangeAttribute(Type, string,string). When property is validating it end with exception that object doesnt implement IComparable interface. It's becouse the type passed to constructor must implement IComparable, but type Nullable<int> (or any other primitive type) doesnt implement it. But if I replace range as Range(min,max) everything works fine. The problem is in template Validation.tmpl witch in every situation use Range(Type,string,string)
I have propery witch is Int and can be null. I set min and max as range. When I generate class DataAnnotation RangeAttribute is added to property. Attribute use constructor RangeAttribute(Type, string,string). When property is validating it end with exception that object doesnt implement IComparable interface. It's becouse the type passed to constructor must implement IComparable, but type Nullable<int> (or any other primitive type) doesnt implement it. But if I replace range as Range(min,max) everything works fine. The problem is in template Validation.tmpl witch in every situation use Range(Type,string,string)