* 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)
53 lines
1.2 KiB
C#
53 lines
1.2 KiB
C#
using System.Globalization;
|
|
using NPoco;
|
|
|
|
namespace Umbraco.Cms.Persistence.Sqlite.Mappers;
|
|
|
|
public class SqlitePocoGuidMapper : DefaultMapper
|
|
{
|
|
public override Func<object, object?> GetFromDbConverter(Type destType, Type sourceType)
|
|
{
|
|
if (destType == typeof(Guid))
|
|
{
|
|
return value =>
|
|
{
|
|
var result = Guid.Parse($"{value}");
|
|
return result;
|
|
};
|
|
}
|
|
|
|
if (destType == typeof(Guid?))
|
|
{
|
|
return value =>
|
|
{
|
|
if (Guid.TryParse($"{value}", out Guid result))
|
|
{
|
|
return result;
|
|
}
|
|
|
|
return default(Guid?);
|
|
};
|
|
}
|
|
|
|
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);
|
|
}
|
|
}
|