Skip to content
This repository was archived by the owner on Dec 24, 2022. It is now read-only.

Commit e4ea45a

Browse files
committed
More defensive approach for DateTime convertion
1 parent d3f63cc commit e4ea45a

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/ServiceStack.OrmLite.SqlServer/SqlServerOrmLiteDialectProvider.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,10 @@ public override object ConvertDbValue(object value, Type type)
101101

102102
if (_ensureUtc && type == typeof (DateTime))
103103
{
104-
var result = (DateTime)base.ConvertDbValue(value, type);
105-
return DateTime.SpecifyKind(result, DateTimeKind.Utc);
104+
var result = base.ConvertDbValue(value, type);
105+
if(result is DateTime)
106+
return DateTime.SpecifyKind((DateTime)result, DateTimeKind.Utc);
107+
return result;
106108
}
107109

108110
if (type == typeof(byte[]))

0 commit comments

Comments
 (0)