From 6cb1748237154b5f2c0b3c6241023c3538b146c0 Mon Sep 17 00:00:00 2001 From: Christopher Jolly Date: Wed, 26 Apr 2023 00:57:45 +0800 Subject: [PATCH] Remove sbyte from clr mappings. Not needed as EF Core will use automatic conversions for those types. EF Core SQL Server behaves the same --- .../Storage/Internal/JetDecimalTypeMapping.cs | 12 +++++++++++- .../Storage/Internal/JetTypeMappingSource.cs | 5 +---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/EFCore.Jet/Storage/Internal/JetDecimalTypeMapping.cs b/src/EFCore.Jet/Storage/Internal/JetDecimalTypeMapping.cs index c60c07a..5b313a6 100644 --- a/src/EFCore.Jet/Storage/Internal/JetDecimalTypeMapping.cs +++ b/src/EFCore.Jet/Storage/Internal/JetDecimalTypeMapping.cs @@ -24,7 +24,7 @@ namespace EntityFrameworkCore.Jet.Storage.Internal DbType? dbType = null, int? precision = null, int? scale = null, - StoreTypePostfix storeTypePostfix = StoreTypePostfix.None) + StoreTypePostfix storeTypePostfix = StoreTypePostfix.PrecisionAndScale) : base( new RelationalTypeMappingParameters( new CoreTypeMappingParameters(typeof(decimal)), @@ -70,6 +70,16 @@ namespace EntityFrameworkCore.Jet.Storage.Internal { parameter.Size = Size.Value; } + + if (Precision.HasValue) + { + parameter.Precision = unchecked((byte)Precision.Value); + } + + if (Scale.HasValue) + { + parameter.Scale = unchecked((byte)Scale.Value); + } } } } \ No newline at end of file diff --git a/src/EFCore.Jet/Storage/Internal/JetTypeMappingSource.cs b/src/EFCore.Jet/Storage/Internal/JetTypeMappingSource.cs index f8f6f46..1b4d127 100644 --- a/src/EFCore.Jet/Storage/Internal/JetTypeMappingSource.cs +++ b/src/EFCore.Jet/Storage/Internal/JetTypeMappingSource.cs @@ -40,7 +40,7 @@ namespace EntityFrameworkCore.Jet.Storage.Internal private readonly JetFloatTypeMapping _single = new JetFloatTypeMapping("single"); private readonly JetDoubleTypeMapping _double = new JetDoubleTypeMapping("double"); - private readonly JetDecimalTypeMapping _decimal = new JetDecimalTypeMapping("decimal", DbType.Decimal, precision: 18, scale: 10, StoreTypePostfix.PrecisionAndScale); + private readonly JetDecimalTypeMapping _decimal = new JetDecimalTypeMapping("decimal", DbType.Decimal, precision: 18, scale: 2, StoreTypePostfix.PrecisionAndScale); private readonly JetCurrencyTypeMapping _currency = new JetCurrencyTypeMapping("currency"); private readonly JetDateTimeTypeMapping _datetime; @@ -181,14 +181,11 @@ namespace EntityFrameworkCore.Jet.Storage.Internal {"timestamp", _rowversion}, }; - // Note: sbyte, ushort, uint, char, long and ulong type mappings are not supported by Jet. - // We would need the type conversions feature to allow this to work - see https://github.com/aspnet/EntityFramework/issues/242. _clrTypeMappings = new Dictionary { {typeof(bool), _bool}, {typeof(byte), _byte}, - {typeof(sbyte), _smallint}, {typeof(short), _smallint}, {typeof(int), _integer}, {typeof(long), _bigint},