[英]NHibernate Fluent CompositeId with CustomType mapping
I have trouble creating the following 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");
Previously Dtg is not part of CompositeId so I can just put Dtg as: 以前Dtg不属于CompositeId,因此我可以将Dtg设置为:
Map(x => x.Dtg, "DTG").CustomType("DateTime2");
It requires DateTime2 as millisecond is required. 由于需要毫秒,因此它需要DateTime2。
Now due to a change I will have to make Dtg as part of CompositeId. 现在由于更改,我将不得不将Dtg作为CompositeId的一部分。
So how do I put CustomType to Dtg? 那么如何将CustomType放入Dtg? thanks for your help.
谢谢你的帮助。
Solution found, adding .CustomType<TimestampType>()
does not truncate milliseconds: 找到的解决方案,添加
.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.