public class A_domain { [StringLength(50)] public string Title { get; set; } ... } public class A_view { public string Title { get; set; } } How can I copy the "StringLength" attribute in A_view? So always be sure that the data does not differ. At the moment I did this:
public class A_domain { public const int MaxTitleLength = 50; [StringLength(MaxTitleLength)] public string Title { get; set; } ... } public class A_view { [StringLength(A_domain.MaxTitleLength)] public string Title { get; set; } } Of course it works, but it seems to me that there is some more correct / beautiful solution (because when there are more than one such field, it forces to write a lot of superfluous when that distracts from the essence).
And then how to get this value?
void foo() { A_view a = new A_view(); a.Title //get max length }