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

Commit a979c2a

Browse files
committed
MySql DateTime Column Read 2 donet Datetime type throw error,
1 parent fae59c8 commit a979c2a

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/ServiceStack.OrmLite.MySql/Converters/MySqlDateTimeConverter.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using ServiceStack.OrmLite.Converters;
3-
3+
using MySql.Data.Types;
4+
45
namespace ServiceStack.OrmLite.MySql.Converters
56
{
67
public class MySqlDateTimeConverter : DateTimeConverter
@@ -14,5 +15,14 @@ public override string ToQuotedString(Type fieldType, object value)
1415
var dateTime = (DateTime)value;
1516
return DateTimeFmt(dateTime, "yyyy-MM-dd HH:mm:ss");
1617
}
18+
public override object FromDbValue(object value)
19+
{
20+
if (value is MySqlDateTime)
21+
{
22+
var time = (MySqlDateTime)value;
23+
return time.GetDateTime();
24+
}
25+
return base.FromDbValue(value);
26+
}
1727
}
1828
}

0 commit comments

Comments
 (0)