There is the following class:
public class A
{
[Required]
public string property { get; set; }
}
and it's used by another class like:
public class B
{
public A prop { get; set; }
public A prop2 { get; set; }
}
in my scenario, B.prop.property
should be required while B.prop2.property
should not be [Required]
.
Is there a way to override prop2.property
attribute to be not required? and it also should affect the record recorded in the Database?
if not what is the most recommended practice to deal with such issue?