简体   繁体   中英

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:

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

It requires DateTime2 as millisecond is required.

Now due to a change I will have to make Dtg as part of CompositeId.

So how do I put CustomType to Dtg? thanks for your help.

Solution found, adding .CustomType<TimestampType>() does not truncate milliseconds:

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>();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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