Model:
public class PmTbl
{
[MaxLength(10), Required, Key]
public string Pm { get; set; }
[MaxLength(50), Required]publicstringDescr {get;set; };
}
Action:

可以在 Model 里的添加特性的方式实现多语言错误信息,但这样太麻烦,每个字段都要写:
MaxLength(50, ErrorMessageResourceName ="xxx",ErrorMessageResourceType =typeof(T))
有没有地方可以直接翻译“The field Descr must be a string or array type with a maximum length of '50'.” 来实现多语言的?
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/1727/viewspace-3120486/ ,如需转载,请注明出处,否则将追究法律责任。