5
I have a class Cliente
, which is the basis. In it I have the property Celular
with Data Annotation "Required".
I wonder if it is possible to use a property Cellular in class ClientePersonalizado
, inherited from the base class Cliente
, but without taking the Required
base class in the Cellular property.
Client class:
public class ClienteViewModel
{
[Required(ErrorMessage = "Preencha o {0} do Cliente")]
public string Celular { get; set; }
}
Class Custom Clientele:
public class ClientePersonalizadoViewModel : ClienteViewModel
{
[DisplayFormat(ConvertEmptyStringToNull = false)]
public string Celular { get; set; }
}
I tried to use the properties as virtual
and override
, but it didn’t work.
It is possible to use in this way?
Did any of the answers solve your question? Do you think you can accept one of them? Check out the [tour] how to do this, if you haven’t already. You would help the community by identifying what was the best solution for you. You can accept only one of them. But you can vote on any question or answer you find useful on the entire site
– Maniero