最佳答案
是否有人知道如何使用 System 为 DateTime 属性指定默认值。组件模型默认值属性 OVT? ?
例如,我试着这样做:
[DefaultValue(typeof(DateTime),DateTime.Now.ToString("yyyy-MM-dd"))]
public DateTime DateCreated { get; set; }
它期望值是一个常量表达式。
这是在与 ASP.NET 动态数据一起使用的上下文中。我不想为 DateCreated 列搭建脚手架,而只是提供 DateTime。现在,如果它不存在。我使用实体框架作为我的数据层
干杯,
安德鲁