在带有ef的数据库中使用日期而没有时间

伍特

我应该使用哪个类与ef和asp.net核心(使用数据库postgres)保存日期(无时间)?DateTimeOffset始终尝试节省时间。

public class something
{
        [Column(TypeName="date")]
        [Required]
        public DateTimeOffset StartDate { get; set; }
}
垃圾桶0x

更改StartDateDateTime,而不是DateTimeOffSet

public DateTime StartDate { get; set; }

然后,您可以使用StartDate.DateDateTime.Date)。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章