views:

193

answers:

0

See Ref to:

http://stackoverflow.com/questions/858987/trying-to-get-generic-when-generic-is-not-available

I am trying to write a ValidationAttribute that will ensure that a property value is uniqure:

[UniqueValueValidationAttribute]
object SomeProperty {get; set;}

The attribute knows (or can determine by reflection):

  • The class (Table) the property belongs to;
  • The property name;
  • The entity object at hand

The idea is to get Linq2SQL to generate the proper SQL to query the Table to return a row with a column value equal the proposed value.

If the query returns Null, then the proposed value is fine.
If the query returns the entity object then all well, also.
If the the returned object is not the entity object, then the proposed value is invalid.

Considering the code in the above referenced question: Am I on the right track, but, with some code issues to resolve, or, way off where another approach is more appropriate?

Thanks