I was wondering if there is a way to hide inherited properties on sub types in C#, something like this for instance:
public interface ISupplierLogin : ISupplier
{
[Obsolete]
new string BusinessName { get; set; }
[Obsolete]
new long ABN { get; set; }
[Obsolete]
new DateTime DateRegistered { get; set; }
}
public interface ISupplier
{
bool TradeOnly { get; set; }
[Required]
[DisplayName("Business Name")]
[StringLength(25, ErrorMessage = "The maximum length of business name is 25 characters.")]
[DataType(DataType.Text)]
string BusinessName { get; set; }
[Required]
[DisplayName("Australian Business Number")]
[ABNValidator(ErrorMessage="The ABN you entered does not appear to be valid.")]
long ABN { get; set; }
[Required]
[RegularExpression("^[a-zA-Z0-9]+$", ErrorMessage="The username you entered does not appear to be valid. (a-z & 0-9)")]
[StringLength(25, ErrorMessage = "The maximum length of username is 25 characters")]
[DataType(DataType.Text)]
string Username { get; set; }
[Required]
[StringLength(12, ErrorMessage = "The maximum length of password must be between 8 and 12 characters long.")]
[DataType(DataType.Password)]
string Password { get; set; }
[DisplayName("Date Registered")]
DateTime DateRegistered { get; set; }
}
Where I want to inherit my validation attributes in my view model, but only for two properties.
Is there anyway to achieve what I am trying to do neatly?
Thanks.