You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
dynamicentry=new ExpandoObject();
entry.time = DateTimeOffset.Now;
entry.distance =6000;
entry.duration = TimeSpan.FromMinutes(31);
entry.UserId =userId;// The userId value comes from another query
db.JournalEntry.Insert(entry);
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.
The text was updated successfully, but these errors were encountered:
When inserting a record with the
datetimeoffset
column type, using aDateTimeOffset
.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:
I'm inserting data into it like this:
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 includeDateTimeOffset
in itsBaseTypes
set.The text was updated successfully, but these errors were encountered: