When inserting a record with the datetimeoffset column type, using a DateTimeOffset .NET structure seems to truncate the milliseconds of the inserted value.
As an example, I have a table defined in SQL Server 2012 Express like this:
CREATE TABLE [dbo].[JournalEntry](
[EntryId] [int] IDENTITY(1,1) PRIMARY KEY CLUSTERED,
[UserId] [int] NOT NULL REFERENCES [dbo].[User](UserId),
[Time] [datetimeoffset](4) NOT NULL,
[Distance] [int] NOT NULL,
[Duration] [time] NOT NULL
I'm inserting data into it like this:
dynamic entry = new ExpandoObject();
entry.time = DateTimeOffset.Now;
entry.distance = 6000;
entry.duration = TimeSpan.FromMinutes(31);
entry.UserId = userId; // The userId value comes from another query
As an example, when running while I'm writing this, according to my debugger, the time value is "2012-12-03T19:28:59.8001074+01:00".
However, after insertion into the database, the value, according to a SQL SELECT statement is "2012-12-03 19:28:59.0000 +01:00". Notice that the sub-second part of the value has been truncated.
As far as I can tell, this happens because Simple.Data.Ado.TypeHelper doesn't include DateTimeOffset in its BaseTypes set.
Fix for issue #249
The fix solves my issue. Thank you for the fast response.
I don't know what your protocol is for issues in this project, but for my sake the issue can be closed now :)
Protocol!? Like I'm that organised. I fix it, you say it worked, I close it.