Is there a way to specify that I want all of the DateTime
s that OrmLite materializes to be set to UTC kind?
I store a lot of DateTime
s in my database via stored procedures when a row is inserted:
insert [Comment] (
Body
, CreatedOn
) values (
@Body
, getutcdate()
);
When I retrieve the values via a select statement in ormlite, the datetimes come out in Unspecified
kind (which is interpreted as the local timezone, I believe):
var comments = db.SqlList<Comment>("select * from [Comment] where ... ");
I would prefer not to set each DateTime object individually:
foreach (var comment in comments) {
comment.CreatedOn = DateTime.SpecifyKind(comment.CreatedOn, DateTimeKind.Utc);
}
I found this question, but I don't think it's quite what I'm asking for:
servicestack ormlite sqlite DateTime getting TimeZone adjustment on insert
Also found this pull request, but setting SqlServerOrmLiteDialectProvider.EnsureUtc(true)
doesn't seem to do it either.