Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想强制 EntityFramework 以秒精度保存日期。
我怎样才能做到这一点 ?
如果我理解您可以像这样设置您的日期时间字段:
obj.Field = DateTime.Now.AddDays(1).ToString("yyyy-MM-dd hh:mm:ss");
或者
obj.Field = dateTime.AddTicks( - (dateTime.Ticks % TimeSpan.TicksPerSecond));