diff --git a/src/NPoco/Database.cs b/src/NPoco/Database.cs index d4cd6273..f90f6d7e 100644 --- a/src/NPoco/Database.cs +++ b/src/NPoco/Database.cs @@ -632,7 +632,11 @@ public T ExecuteScalar(string sql, CommandType commandType, params object[] a Type t = typeof(T); Type u = Nullable.GetUnderlyingType(t); - return (T)Convert.ChangeType(val, u ?? t); + var converter = MappingHelper.GetConverter(Mappers, null, val.GetType(), t); + + return converter != null + ? (T)converter.Invoke(val) + : (T)Convert.ChangeType(val, u ?? t); } } catch (Exception x)