Add new UtcDateTime2Type to handle DateTime2

Description

I use UtcDateTimeType and CustomSqlType "dateTime2" (configured with FluentNhibernate conventions).

SchemaExport generates the database-columns with dateTime2 - just as expected.
But when I try to save an entity with an DateTime column having DateTime.Min as value, an SQL exception known from datetime (without "2") gets thrown: {{ SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM.}}

It seems that UtcDateTimeType and sql-type datetime2 are incompatible.

I created an UserType which is basically a copy of AbstractDateTime2SpecificKindType with some ingredients from DateTime2Type and SqlTypeFactory.DateTime2 passed on to its base-class DateTimeType.
This works.

Attached you find the used source code.
I think it would be useful if this kind of user-type would ship with NHibernate itself. As the the internal constructor of DateTime2Type wasn't available to me but is you I think a proper built-in user-type is would be much cleaner.
No tests except It-Saves-Stores-And-Loads-Correctly-For-Me-testing

Environment

Windows 8.1 Pro x64, SqlServer 2012 Express

Attachments

1

Activity

Show:

Alex Zaytsev 
October 12, 2017 at 2:11 PM

Obsolete by

Obsolete

Details

Assignee

Reporter

Labels

Components

Affects versions

Priority

Who's Looking?

Open Who's Looking?
Created May 20, 2015 at 12:36 PM
Updated October 16, 2017 at 10:12 PM
Resolved October 12, 2017 at 2:11 PM
Who's Looking?