繁体   English   中英

NHibernate Fluent CompositeId与CustomType映射

[英]NHibernate Fluent CompositeId with CustomType mapping

我在创建以下映射时遇到麻烦:

CompositeId(x => x.Id)
    .KeyProperty(x => x.SiteId, "SiteID")
    .KeyProperty(x => x.SomeId, "SomeId")
    .KeyProperty(x => x.AnotherId, "AnotherId")
    .KeyProperty(x => x.Dtg, "DTG");

以前Dtg不属于CompositeId,因此我可以将Dtg设置为:

Map(x => x.Dtg, "DTG").CustomType("DateTime2");

由于需要毫秒,因此它需要DateTime2。

现在由于更改,我将不得不将Dtg作为CompositeId的一部分。

那么如何将CustomType放入Dtg? 谢谢你的帮助。

找到的解决方案,添加.CustomType<TimestampType>()不会截断毫秒:

CompositeId(x => x.Id)
.KeyProperty(x => x.SiteId, "SiteID")
.KeyProperty(x => x.SomeId, "SomeId")
.KeyProperty(x => x.AnotherId, "AnotherId")
.KeyProperty(x => x.Dtg, "DTG").CustomType<TimestampType>();

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM