This libarary is a collection of NHibernate custom value types for NodaTime. Current custom types inclue:
- AnnualDate
- DateInterval
- Duration
- Instant
- Interval
- LocalDate
- LocalDateTime
- LocalTime
- Offset
- OffsetDate
- OffsetDateTime
- OffsetTime
- Period
- ZonedDateTime
You can either use the custom value types in your ClassMapping<>
by declaring the column(s) and property type, or use the helper methods.
To use the helper methods, change your mapping class to derive from NodaTimeClassMapping<>
instead of ClassMapping<>
.
The Property method's Action<IPropertyMapper> mapping
parameter you pass into the helper methods will take precedence.
Property(p => p.AnnualDate,
m =>
{
m.Columns(
cm => cm.Name("AnnualDate_Month"), // Int32
cm => cm.Name("AnnualDate_Day")); // Int32
m.Type<NodaTimeAnnualDateUserType>();
});
or
AnnualDateProperty(p => p.AnnualDate);
Property(p => p.DateInterval,
m =>
{
m.Columns(
cm => cm.Name("DateInterval_Start"), // Int64
cm => cm.Name("DateInterval_End"), // Int64
cm => cm.Name("DateInterval_Calendar")); // String
m.Type<NodaTimeDateIntervalUserType>();
});
or
DateIntervalProperty(p => p.DateInterval);
Property(p => p.Duration, m => m.Type<NodaTimeDurationUserType>()); // Int64
or
DurationProperty(p => p.Duration);
Property(p => p.Instant, m => m.Type<NodaTimeInstantUserType>()); // Int64
or
InstantProperty(p => p.Instant);
Property(p => p.Interval,
m =>
{
m.Columns(
cm => cm.Name("Interval_Interval"), // Boolean
cm => cm.Name("Interval_Start"), // Int64
cm => cm.Name("Interval_End")); // Int64
m.Type<NodaTimeIntervalUserType>();
});
or
IntervalProperty(p => p.Interval);
Property(p => p.LocalDate,
m =>
{
m.Columns(
cm => cm.Name("LocalDate_Date"), // Int64
cm => cm.Name("LocalDate_Calendar")); // String
m.Type<NodaTimeLocalDateUserType>();
});
or
LocalDateProperty(p => p.LocalDate);
Property(p => p.LocalDateTime,
m =>
{
m.Columns(
cm => cm.Name("LocalDateTime_DateTime"), // Int64
cm => cm.Name("LocalDateTime_Calendar")); // String
m.Type<NodaTimeLocalDateUserType>();
});
or
LocalDateTimeProperty(p => p.LocalDateTime);
Property(p => p.LocalTime, m => m.Type<NodaTimeLocalTimeUserType>()); // Int64
or
LocalTimeProperty(p => p.LocalTime);
Property(p => p.Offset, m => m.Type<NodaTimeOffsetUserType>()); // Int64
or
OffsetProperty(p => p.Offset);
Property(p => p.OffsetDate,
m =>
{
m.Columns(
cm => cm.Name("OffsetDate_Date"), // Int64
cm => cm.Name("OffsetDate_Offset"), // Int64
cm => cm.Name("OffsetDate_Calendar")); // String
m.Type<NodaTimeOffsetDateUserType>();
});
or
OffsetDateProperty(p => p.OffsetDate);
Property(p => p.OffsetDateTime,
m =>
{
m.Columns(
cm => cm.Name("OffsetDateTime_DateTime"), // Int64
cm => cm.Name("OffsetDateTime_Offset"), // Int64
cm => cm.Name("OffsetDateTime_Calendar")); // String
m.Type<NodaTimeOffsetDateTimeUserType>();
});
or
OffsetDateTimeProperty(p => p.OffsetDateTime);
Property(p => p.OffsetTime,
m =>
{
m.Columns(
cm => cm.Name("OffsetTime_Time"), // Int64
cm => cm.Name("OffsetTime_Offset")); // Int64
m.Type<NodaTimeOffsetTimeUserType>();
});
or
OffsetTimeProperty(p => p.OffsetTime);
Property(p => p.Period,
m =>
{
m.Columns(
cm => cm.Name("Period_Days"), // Int32
cm => cm.Name("Period_Hours"), // Int64
cm => cm.Name("Period_Milliseconds"), // Int64
cm => cm.Name("Period_Minutes"), // Int64
cm => cm.Name("Period_Months"), // Int32
cm => cm.Name("Period_Nanoseconds"), // Int64
cm => cm.Name("Period_Seconds"), // Int64
cm => cm.Name("Period_Ticks"), // Int64
cm => cm.Name("Period_Weeks"), // Int32
cm => cm.Name("Period_Years")); // Int32
m.Type<NodaTimePeriodUserType>();
});
or
PeriodProperty(p => p.Period);
Property(p => p.ZonedDateTime,
m =>
{
m.Columns(
cm => cm.Name("ZonedDateTime_DateTime"), // Int64
cm => cm.Name("ZonedDateTime_Zone"), // String
cm => cm.Name("ZonedDateTime_Calendar")); // String
m.Type<NodaTimeZonedDateTimeUserType>();
});
or
ZonedDateTimeProperty(p => p.ZonedDateTime);