[英]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.