System.Data.SQLite
View Ticket
Not logged in
Ticket UUID: a799e3978f6fa5a2ab333035cc4a5ba1ec5af48f
Title: Add support for DbType.DateTime2 parameter type
Status: Closed Type: Feature_Request
Severity: Important Priority: Medium
Subsystem: Convert Resolution: Fixed
Last Modified: 2018-01-24 22:36:54
Version Found In: 1.0.86.0
User Comments:
anonymous added on 2014-01-16 11:38:02:
To add compatibility with "DateTimeFormat", "DateTimeFormatString" and "DateTimeKind" options and to reflect the actual time precision supported by SQLite.

anonymous added on 2014-08-25 10:04:17:
Any chance to see this fixed?

anonymous added on 2018-01-14 21:58:47:
It seems like simply treating datetime2 as if it was datetime would save a lot of headaches. Is there a concern that this kind of change would break something else?

mistachkin added on 2018-01-24 16:48:06:
I've looked into adding this support before.  If I remember correctly, it would
be very difficult to maintain backward compatibility with existing databases and
their data types.

Further, DateTime2 appears to be SQL Server specific.

It should be noted that it is possible to customize the data type mappings used
by System.Data.SQLite on a per-connection basis.  That way, if a database schema
includes the type name DATETIME2, you should be able to map it to the DateTime2
DbType.  I'll try to add some tests to verify this is possible.

mistachkin added on 2018-01-24 18:48:21:
Confirmed.  Using the latest version of System.Data.SQLite, you can add a custom
type mapping for DATETIME2 that maps to the DbType DateTime using code similar to
the following:

  SQLiteConnection cnn = new SQLiteConnection("Data Source=:memory:;");
  cnn.Open();
  cnn.AddTypeMapping("DATETIME2", DbType.DateTime, false);