如何避免在带有DataAnnotations的错误消息中使用硬编码字符串?

时间:2014-07-31 15:54:52

标签: c# asp.net-web-api validation

我的问题如下:

有没有机会避免硬编码字符串来设置ErrorMessage =“..”?

[Required(ErrorMessage="My message harcoded")]

public int ID { get; set; }

我不能使用这样的方法,因为ErrorMessage只接受const。

[Required(ErrorMessage = GetErrorMessage())]

public int ID { get; set; }

0 个答案:

没有答案