我的模型类Base1上有一个 System.ComponentModel.DataAnnotations格式化 DateTime 类型。
[DisplayFormat(DataFormatString = "{0:yyyy-MM-dd}")]
public DateTime Date { get; set; }
当我从Base1和Base2模型创建另一个模型时
public class Combined
{
public Base1 Name1 { get; set; }
public Base2 Name2 { get; set; }
}
Name1 实例中的 DateTime 格式更改为默认值(数据和时间)。
有没有办法从基本模型“继承” DataAnnotations,所以我不必在视图层上格式化显示数据?