DataAnnotations vs IDataErrorInfo

后端 未结 3 718
情深已故
情深已故 2021-01-02 17:46

DataAnnotations vs IDataErrorInfo

Pros and Cons of both? Benefits of one over the other? (especially related to MVC)

3条回答
  •  孤城傲影
    2021-01-02 18:16

    DataAnnotations are easier to implement, and getting directly support in MVC 2.0.

    However, IDataErrorInfo allows you do to more complex validation (ie: validation that spawns multiple properties, etc).

    The two can be mixed, and used together, however. There is nothing stopping you from implementing both techniques.

提交回复
热议问题