Permalink
Browse files

More defensive approach for DateTime convertion

  • Loading branch information...
kojoru committed Apr 2, 2013
1 parent d3f63cc commit e4ea45aa48cdbb14f7a89bfd3400736d25a2d1ef
Showing with 4 additions and 2 deletions.
  1. +4 −2 src/ServiceStack.OrmLite.SqlServer/SqlServerOrmLiteDialectProvider.cs
@@ -101,8 +101,10 @@ public override object ConvertDbValue(object value, Type type)
if (_ensureUtc && type == typeof (DateTime))
{
- var result = (DateTime)base.ConvertDbValue(value, type);
- return DateTime.SpecifyKind(result, DateTimeKind.Utc);
+ var result = base.ConvertDbValue(value, type);
+ if(result is DateTime)
+ return DateTime.SpecifyKind((DateTime)result, DateTimeKind.Utc);
+ return result;
}
if (type == typeof(byte[]))

0 comments on commit e4ea45a

Please sign in to comment.