servicestack ormlite sqlite DateTime getting TimeZone adjustment on insert
Asked Answered
S

2

3

i'm trying ormlite. i'm finding that when i insert an object with a DateTime property, it is getting -8:00 (my timezone is +8) applied by ormlite. It should be inserted with literally what the time is. in my case it is already UTC.

however reading the values out of ormlite, the +8 is not getting re-applied.

is this a known bug?

thanks

Shortfall answered 10/1, 2013 at 4:13 Comment(1)
ormlite 3.9.32 sqlite 32bitShortfall
I
0

I think it is inserted in UTC kind. After reading DateTime from database try to apply .ToLocalTime()

Illfavored answered 31/1, 2013 at 20:37 Comment(0)
V
0

So your question looks related to this pull request: https://github.com/kojoru/ServiceStack.OrmLite/commit/d3f63ccd40f945b8dc03fd627ad49a895d4277de

If you check the code in SqlServerOrmLiteDialectProvider.cs, it looks like setting SqlServerOrmLiteDialectProvider.EnsureUtc(true) would fix your problem.

var dialect = new SqlServerOrmLiteDialectProvider();
dialect.EnsureUtc(true);
var factory = new OrmLiteConnectionFactory(cnnStr, dialect);
var connection = factory.Open();

Check EnsureUtcTest.cs for an example. Old question, I know, but I hope that helps.

Volution answered 2/9, 2013 at 20:59 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.