V11: Fix decimal variants (#13741)

* fix sqlite with variants

* Create and register SqlSpecificMapper

* Delete obsolete file

* Add back inheritance

Co-authored-by: Zeegaan <nge@umbraco.dk>
(cherry picked from commit c868c60ed2)
This commit is contained in:
Nikolaj Geisle
2023-01-26 12:26:06 +01:00
committed by Sebastiaan Janssen
parent f9aaf1984a
commit 747f2e7599
4 changed files with 62 additions and 0 deletions

View File

@@ -0,0 +1,30 @@
using System.Globalization;
using NPoco;
namespace Umbraco.Cms.Core.Mapping;
public class UmbracoDefaultMapper : DefaultMapper
{
public override Func<object, object?> GetFromDbConverter(Type destType, Type sourceType)
{
if (destType == typeof(decimal))
{
return value =>
{
var result = Convert.ToDecimal(value, CultureInfo.InvariantCulture);
return result;
};
}
if (destType == typeof(decimal?))
{
return value =>
{
var result = Convert.ToDecimal(value, CultureInfo.InvariantCulture);
return result;
};
}
return base.GetFromDbConverter(destType, sourceType);
}
}