Attribute on Interface members does not work

后端 未结 1 1525
悲哀的现实
悲哀的现实 2020-11-30 11:32

In my application several models need Password properties (eg, Registration and ChangePassword models). The Password prop

相关标签:
1条回答
  • 2020-11-30 11:54

    Attributes on interface properties doesn't get inherited to the class, you may make your interface an Abstract Class.

    Found an answer from Microsoft:

    The product team does not want to implement this feature, for two main reasons:

    • Consistency with DataAnnotations.Validator
    • Consistency with validation behavior in ASP.Net MVC
    • tricky scenario: a class implements two interfaces that have the same property, but with conflicting attributes on them. Which attribute would take precedence?
    0 讨论(0)
提交回复
热议问题