Merge remote-tracking branch 'origin/v12/dev' into v13/dev

This commit is contained in:
Bjarke Berg
2023-01-30 08:02:44 +01:00
6 changed files with 63 additions and 5 deletions

View File

@@ -0,0 +1,11 @@
using Umbraco.Cms.Core.Mapping;
using Umbraco.Cms.Infrastructure.Persistence;
namespace Umbraco.Cms.Persistence.SqlServer.Services;
public class SqlServerSpecificMapperFactory : IProviderSpecificMapperFactory
{
public string ProviderName => Constants.ProviderName;
public NPocoMapperCollection Mappers => new(() => new[] { new UmbracoDefaultMapper() });
}

View File

@@ -22,6 +22,8 @@ public static class UmbracoBuilderExtensions
/// </summary>
public static IUmbracoBuilder AddUmbracoSqlServerSupport(this IUmbracoBuilder builder)
{
builder.Services.TryAddEnumerable(ServiceDescriptor
.Singleton<IProviderSpecificMapperFactory, SqlServerSpecificMapperFactory>());
builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton<ISqlSyntaxProvider, SqlServerSyntaxProvider>());
builder.Services.TryAddEnumerable(ServiceDescriptor
.Singleton<IBulkSqlInsertProvider, SqlServerBulkSqlInsertProvider>());

View File

@@ -1,3 +1,4 @@
using System.Globalization;
using NPoco;
namespace Umbraco.Cms.Persistence.Sqlite.Mappers;
@@ -28,6 +29,24 @@ public class SqlitePocoGuidMapper : DefaultMapper
};
}
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);
}
}

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);
}
}

View File

@@ -22,10 +22,6 @@ public class BTree
// default is 4096, min 2^9 = 512, max 2^16 = 64K
FileBlockSize = GetBlockSize(settings),
// HACK: Forces FileOptions to be WriteThrough here: https://github.com/mamift/CSharpTest.Net.Collections/blob/9f93733b3af7ee0e2de353e822ff54d908209b0b/src/CSharpTest.Net.Collections/IO/TransactedCompoundFile.cs#L316-L327,
// as the reflection uses otherwise will failed in .NET Core as the "_handle" field in FileStream is renamed to "_fileHandle".
StoragePerformance = StoragePerformance.CommitToDisk,
// other options?
};

View File

@@ -7,8 +7,8 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="CSharpTest.Net.Collections-NetStd2" Version="14.907.0" />
<PackageReference Include="MessagePack" Version="2.4.59" />
<PackageReference Include="Umbraco.CSharpTest.Net.Collections" Version="15.0.0" />
<PackageReference Include="K4os.Compression.LZ4" Version="1.2.16" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
</ItemGroup>