作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在当前项目中使用 Fluent Nhibernate 和 Nhibernate。我需要将时间记录到毫秒。我有这个用于我的映射
Map(x => x.SystemDateTime)
.CustomType("Timestamp")
.Not.Nullable();
<property name="SystemDateTime" type="Timestamp">
<column name="SystemDateTime" not-null="true" />
</property>
最佳答案
我们使用与您相同的方法,它确实正确存储了毫秒。如果您不总是这样做,尽管您的旧记录将丢失毫秒。
假设您想为所有 DateTime 字段存储毫秒,您可以使用约定:
public class OurPropertyConventions : IPropertyConvention
{
public void Apply(IPropertyInstance instance)
{
Type type = instance.Property.PropertyType;
if (type == typeof(DateTime) || type == typeof(DateTime?))
instance.CustomType("Timestamp");
}
}
Map(x => x.SystemDateTime).Not.Nullable();
关于nhibernate - 流畅的 Nhiberhate 和缺失的毫秒,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2874057/
我在当前项目中使用 Fluent Nhibernate 和 Nhibernate。我需要将时间记录到毫秒。我有这个用于我的映射 Map(x => x.SystemDateTim
我是一名优秀的程序员,十分优秀!