In my project I have several classes with properties that should be unique, and I want to write a custom attribute that can be used on all the properties. For example I have class User with property username and class Application with property name that should be unique and I want to be able to do this:
[Unique(ErrorMessage = "Username alreadey exists")]
public string username {get;set;}
[Unique(ErrorMessage = "Name alreadey exists")]
public string name {get; set;}
Can someone please tell how to do this ?