I have a model like this
public class MyModel
{
public int MyModelId { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public string Title { get; set; }
}
I was wondering if there's a way, using Data Annotations, to set the value of a property - say Title - default to other property value, i.e. Name. Something like:
if(MyModel.Title == "") MyModel.Title = MyModel.Name;
If you want default value set it in entity default (parameterless) constructor. There is no need to have data annotation for something which you can do directly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With