This question is locked. New answers and comments are not allowed.
I'm using the
System.ComponentModel.DataAnnotations namespace to validate my domain classes. How can I create a custom attribute to validate the uniqueness of Name and Email property regardless of the database public partial class T_User{ private int _idUser; [Required()] [Key()] public virtual int IdUser { get { return this._idUser; } set { this._idUser = value; } } private string _name; [StringLength(50)] [Required] public virtual string Name { get { return this._name; } set { this._name = value; } } private string _mail; [StringLength(50)] [Required] [RegularExpression(@"^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$", ErrorMessage = "Adresse mail non valide !")] public virtual string Mail { get { return this._mail; } set { this._mail = value; } } private string _password; [StringLength(50)] [Required] public virtual string Password { get { return this._password; } set { this._password = value; } } private int? _idRole; public virtual int? IdRole { get { return this._idRole; } set { this._idRole = value; } } private T_Role _t_Role; public virtual T_Role T_Role { get { return this._t_Role; } set { this._t_Role = value; } } private IList<R_SiteUser> _r_SiteUsers = new List<R_SiteUser>(); public virtual IList<R_SiteUser> R_SiteUsers { get { return this._r_SiteUsers; } } private IList<R_PrestationUser> _r_PrestationUsers = new List<R_PrestationUser>(); public virtual IList<R_PrestationUser> R_PrestationUsers { get { return this._r_PrestationUsers; } } }