Update to npoco5

This commit is contained in:
Paul Johnson
2022-01-18 15:23:53 +00:00
parent c6d7f3b5d1
commit 2ead758a99
30 changed files with 84 additions and 49 deletions

View File

@@ -5,7 +5,7 @@
public static class DatabaseProviders
{
public const string SqlCe = "System.Data.SqlServerCe.4.0";
public const string SqlServer = "System.Data.SqlClient";
public const string SqlServer = "Microsoft.Data.SqlClient";
}
}
}

View File

@@ -5,7 +5,7 @@ namespace Umbraco.Cms.Core
{
public static class DbProviderNames
{
public const string SqlServer = "System.Data.SqlClient";
public const string SqlServer = "Microsoft.Data.SqlClient";
public const string SqlCe = "System.Data.SqlServerCe.4.0";
}
}

View File

@@ -1,15 +1,11 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Data;
using System.Data.Common;
using System.Data.SqlClient;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Data.SqlClient;
namespace Umbraco.Cms.Infrastructure.Persistence
{

View File

@@ -1,5 +1,5 @@
using System;
using System.Data.SqlClient;
using Microsoft.Data.SqlClient;
namespace Umbraco.Cms.Infrastructure.Persistence.FaultHandling.Strategies
{

View File

@@ -1,5 +1,5 @@
using System;
using System.Data.SqlClient;
using Microsoft.Data.SqlClient;
namespace Umbraco.Cms.Infrastructure.Persistence.FaultHandling.Strategies
{
@@ -104,7 +104,7 @@ namespace Umbraco.Cms.Infrastructure.Persistence.FaultHandling.Strategies
// Resource ID: %d. The %s limit for the database is %d and has been reached.
case 10928:
// SQL Error Code: 10929
// Resource ID: %d. The %s minimum guarantee is %d, maximum limit is %d and the current usage for the database is %d.
// Resource ID: %d. The %s minimum guarantee is %d, maximum limit is %d and the current usage for the database is %d.
// However, the server is currently too busy to support requests greater than %d for this database.
case 10929:
// SQL Error Code: 10053
@@ -112,14 +112,14 @@ namespace Umbraco.Cms.Infrastructure.Persistence.FaultHandling.Strategies
// An established connection was aborted by the software in your host machine.
case 10053:
// SQL Error Code: 10054
// A transport-level error has occurred when sending the request to the server.
// A transport-level error has occurred when sending the request to the server.
// (provider: TCP Provider, error: 0 - An existing connection was forcibly closed by the remote host.)
case 10054:
// SQL Error Code: 10060
// A network-related or instance-specific error occurred while establishing a connection to SQL Server.
// The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server
// is configured to allow remote connections. (provider: TCP Provider, error: 0 - A connection attempt failed
// because the connected party did not properly respond after a period of time, or established connection failed
// A network-related or instance-specific error occurred while establishing a connection to SQL Server.
// The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server
// is configured to allow remote connections. (provider: TCP Provider, error: 0 - A connection attempt failed
// because the connected party did not properly respond after a period of time, or established connection failed
// because connected host has failed to respond.)"}
case 10060:
// SQL Error Code: 40197
@@ -129,21 +129,21 @@ namespace Umbraco.Cms.Infrastructure.Persistence.FaultHandling.Strategies
// The service has encountered an error processing your request. Please try again.
case 40540:
// SQL Error Code: 40613
// Database XXXX on server YYYY is not currently available. Please retry the connection later. If the problem persists, contact customer
// Database XXXX on server YYYY is not currently available. Please retry the connection later. If the problem persists, contact customer
// support, and provide them the session tracing ID of ZZZZZ.
case 40613:
// SQL Error Code: 40143
// The service has encountered an error processing your request. Please try again.
case 40143:
// SQL Error Code: 233
// The client was unable to establish a connection because of an error during connection initialization process before login.
// Possible causes include the following: the client tried to connect to an unsupported version of SQL Server; the server was too busy
// to accept new connections; or there was a resource limitation (insufficient memory or maximum allowed connections) on the server.
// The client was unable to establish a connection because of an error during connection initialization process before login.
// Possible causes include the following: the client tried to connect to an unsupported version of SQL Server; the server was too busy
// to accept new connections; or there was a resource limitation (insufficient memory or maximum allowed connections) on the server.
// (provider: TCP Provider, error: 0 - An existing connection was forcibly closed by the remote host.)
case 233:
// SQL Error Code: 64
// A connection was successfully established with the server, but then an error occurred during the login process.
// (provider: TCP Provider, error: 0 - The specified network name is no longer available.)
// A connection was successfully established with the server, but then an error occurred during the login process.
// (provider: TCP Provider, error: 0 - The specified network name is no longer available.)
case 64:
// DBNETLIB Error Code: 20
// The instance of SQL Server you attempted to connect to does not support encryption.

View File

@@ -1,10 +1,10 @@
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using Microsoft.Data.SqlClient;
namespace Umbraco.Cms.Infrastructure.Persistence.FaultHandling
{

View File

@@ -1,10 +1,10 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Diagnostics;
using System.IO;
using System.Linq;
using Microsoft.Data.SqlClient;
namespace Umbraco.Cms.Infrastructure.Persistence
{

View File

@@ -2,9 +2,10 @@
using System.Collections.Generic;
using System.Data;
using System.Data.Common;
using System.Data.SqlClient;
using System.Linq;
using Microsoft.Data.SqlClient;
using NPoco;
using NPoco.SqlServer;
using Umbraco.Cms.Core;
using Umbraco.Cms.Infrastructure.Persistence;

View File

@@ -1,8 +1,8 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Text.RegularExpressions;
using Microsoft.Data.SqlClient;
using NPoco;
using StackExchange.Profiling.Data;
using Umbraco.Cms.Infrastructure.Persistence;

View File

@@ -1,8 +1,8 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using Microsoft.Data.SqlClient;
using NPoco;
using Umbraco.Cms.Infrastructure.Persistence.SqlSyntax;
using Umbraco.Extensions;

View File

@@ -1,6 +1,6 @@
using System;
using System.Data.SqlClient;
using System.IO;
using Microsoft.Data.SqlClient;
using Umbraco.Cms.Core;
namespace Umbraco.Cms.Infrastructure.Persistence

View File

@@ -1,8 +1,8 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using Microsoft.Data.SqlClient;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using NPoco;

View File

@@ -292,7 +292,7 @@ namespace Umbraco.Cms.Infrastructure.Persistence
_pocoMappers.AddRange(_dbProviderFactoryCreator.ProviderSpecificMappers(_providerName));
var factory = new FluentPocoDataFactory(GetPocoDataFactoryResolver);
var factory = new FluentPocoDataFactory(GetPocoDataFactoryResolver, _pocoMappers);
_pocoDataFactory = factory;
var config = new FluentConfig(xmappers => factory);

View File

@@ -1,15 +1,14 @@
using System;
using System.Data;
using System.Data.SqlClient;
using System.Diagnostics;
using System.Linq;
using System.Security.Cryptography;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Data.SqlClient;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using NPoco;
using Umbraco.Cms.Core;
using Umbraco.Cms.Core.Configuration.Models;
using Umbraco.Cms.Core.Hosting;
using Umbraco.Cms.Core.Runtime;

View File

@@ -36,7 +36,7 @@
<PackageReference Include="MiniProfiler.Shared" Version="4.2.22" />
<PackageReference Include="ncrontab" Version="3.3.1" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="NPoco" Version="4.0.2" />
<PackageReference Include="NPoco.SqlServer" Version="5.3.2" />
<PackageReference Include="Serilog" Version="2.10.0" />
<PackageReference Include="Serilog.Enrichers.Process" Version="2.0.2" />
<PackageReference Include="Serilog.Enrichers.Thread" Version="3.1.0" />
@@ -49,7 +49,6 @@
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
<PackageReference Include="Serilog.Sinks.Map" Version="1.0.2" />
<PackageReference Include="SixLabors.ImageSharp" Version="1.0.4" />
<PackageReference Include="System.Data.SqlClient" Version="4.8.3" />
<PackageReference Include="System.IO.FileSystem.AccessControl" Version="5.0.0" />
<PackageReference Include="System.Text.Encodings.Web" Version="6.0.0" /> <!-- Explicit updated this nested dependency due to this https://github.com/dotnet/announcements/issues/178-->
<PackageReference Include="System.Threading.Tasks.Dataflow" Version="6.0.0" />

View File

@@ -1,6 +1,5 @@
using System;
using System.Data.Common;
using System.Data.SqlClient;
using System.IO;
using System.Linq;
using System.Reflection;
@@ -11,6 +10,7 @@ using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc.ApplicationModels;
using Microsoft.AspNetCore.Mvc.Razor.Compilation;
using Microsoft.AspNetCore.Server.Kestrel.Core;
using Microsoft.Data.SqlClient;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;

View File

@@ -33,8 +33,8 @@ namespace Umbraco.Tests.Benchmarks
public SqlTemplatesBenchmark()
{
var mappers = new NPoco.MapperCollection( );
var factory = new FluentPocoDataFactory((type, iPocoDataFactory) => new PocoDataBuilder(type, mappers).Init());
var mappers = new NPoco.MapperCollection();
var factory = new FluentPocoDataFactory((type, iPocoDataFactory) => new PocoDataBuilder(type, mappers).Init(), mappers);
SqlContext = new SqlContext(new SqlServerSyntaxProvider(Options.Create(new GlobalSettings())), DatabaseType.SQLCe, factory);
SqlTemplates = new SqlTemplates(SqlContext);

View File

@@ -86,6 +86,8 @@ namespace Umbraco.Cms.Tests.Common.TestHelpers
{
}
(List<T1>, List<T2>, List<T3>, List<T4>) IDatabaseQuery.FetchMultiple<T1, T2, T3, T4>(Sql sql) => throw new NotImplementedException();
public int OneTimeCommandTimeout { get; set; }
public MapperCollection Mappers { get; set; }
@@ -182,14 +184,17 @@ namespace Umbraco.Cms.Tests.Common.TestHelpers
public Task<int> ExecuteAsync(string sql, params object[] args) => throw new NotImplementedException();
public Task<int> ExecuteAsync(Sql sql) => throw new NotImplementedException();
public Task<object> InsertAsync(string tableName, string primaryKeyName, object poco) => throw new NotImplementedException();
public object Insert<T>(string tableName, string primaryKeyName, bool autoIncrement, T poco) => throw new NotImplementedException();
public object Insert<T>(string tableName, string primaryKeyName, T poco) => throw new NotImplementedException();
public object Insert<T>(T poco) => throw new NotImplementedException();
public void InsertBulk<T>(IEnumerable<T> pocos, InsertBulkOptions? options = null) => throw new NotImplementedException();
public Task<object> InsertAsync<T>(T poco) => throw new NotImplementedException();
public Task InsertBulkAsync<T>(IEnumerable<T> pocos, InsertBulkOptions options = null) => throw new NotImplementedException();
public Task<int> InsertBatchAsync<T>(IEnumerable<T> pocos, BatchOptions options = null) => throw new NotImplementedException();
@@ -206,6 +211,9 @@ namespace Umbraco.Cms.Tests.Common.TestHelpers
public IAsyncUpdateQueryProvider<T> UpdateManyAsync<T>() => throw new NotImplementedException();
public IAsyncDeleteQueryProvider<T> DeleteManyAsync<T>() => throw new NotImplementedException();
public Task<bool> IsNewAsync<T>(T poco) => throw new NotImplementedException();
public Task SaveAsync<T>(T poco) => throw new NotImplementedException();
public void InsertBulk<T>(IEnumerable<T> pocos) => throw new NotImplementedException();
@@ -350,6 +358,15 @@ namespace Umbraco.Cms.Tests.Common.TestHelpers
public TRet FetchMultiple<T1, T2, T3, TRet>(Func<List<T1>, List<T2>, List<T3>, TRet> cb, Sql sql) => throw new NotImplementedException();
public TRet FetchMultiple<T1, T2, T3, T4, TRet>(Func<List<T1>, List<T2>, List<T3>, List<T4>, TRet> cb, Sql sql) => throw new NotImplementedException();
(List<T1>, List<T2>) IDatabaseQuery.FetchMultiple<T1, T2>(string sql, params object[] args) => throw new NotImplementedException();
(List<T1>, List<T2>, List<T3>) IDatabaseQuery.FetchMultiple<T1, T2, T3>(string sql, params object[] args) => throw new NotImplementedException();
(List<T1>, List<T2>, List<T3>, List<T4>) IDatabaseQuery.FetchMultiple<T1, T2, T3, T4>(string sql, params object[] args) => throw new NotImplementedException();
(List<T1>, List<T2>) IDatabaseQuery.FetchMultiple<T1, T2>(Sql sql) => throw new NotImplementedException();
(List<T1>, List<T2>, List<T3>) IDatabaseQuery.FetchMultiple<T1, T2, T3>(Sql sql) => throw new NotImplementedException();
public Tuple<List<T1>, List<T2>> FetchMultiple<T1, T2>(string sql, params object[] args) => throw new NotImplementedException();
@@ -382,6 +399,9 @@ namespace Umbraco.Cms.Tests.Common.TestHelpers
public Task<T> FirstOrDefaultAsync<T>(string sql, params object[] args) => throw new NotImplementedException();
public Task<T> FirstOrDefaultAsync<T>(Sql sql) => throw new NotImplementedException();
IAsyncEnumerable<T> IAsyncQueryDatabase.QueryAsync<T>(string sql, params object[] args) => throw new NotImplementedException();
IAsyncEnumerable<T> IAsyncQueryDatabase.QueryAsync<T>(Sql sql) => throw new NotImplementedException();
public Task<IEnumerable<T>> QueryAsync<T>(string sql, params object[] args) => throw new NotImplementedException();
@@ -406,6 +426,29 @@ namespace Umbraco.Cms.Tests.Common.TestHelpers
public Task<List<T>> SkipTakeAsync<T>(long skip, long take, string sql, params object[] args) => throw new NotImplementedException();
public Task<List<T>> SkipTakeAsync<T>(long skip, long take, Sql sql) => throw new NotImplementedException();
public Task<TRet> FetchMultipleAsync<T1, T2, TRet>(Func<List<T1>, List<T2>, TRet> cb, string sql, params object[] args) => throw new NotImplementedException();
public Task<TRet> FetchMultipleAsync<T1, T2, T3, TRet>(Func<List<T1>, List<T2>, List<T3>, TRet> cb, string sql, params object[] args) => throw new NotImplementedException();
public Task<TRet> FetchMultipleAsync<T1, T2, T3, T4, TRet>(Func<List<T1>, List<T2>, List<T3>, List<T4>, TRet> cb, string sql, params object[] args) => throw new NotImplementedException();
public Task<TRet> FetchMultipleAsync<T1, T2, TRet>(Func<List<T1>, List<T2>, TRet> cb, Sql sql) => throw new NotImplementedException();
public Task<TRet> FetchMultipleAsync<T1, T2, T3, TRet>(Func<List<T1>, List<T2>, List<T3>, TRet> cb, Sql sql) => throw new NotImplementedException();
public Task<TRet> FetchMultipleAsync<T1, T2, T3, T4, TRet>(Func<List<T1>, List<T2>, List<T3>, List<T4>, TRet> cb, Sql sql) => throw new NotImplementedException();
public Task<(List<T1>, List<T2>)> FetchMultipleAsync<T1, T2>(string sql, params object[] args) => throw new NotImplementedException();
public Task<(List<T1>, List<T2>, List<T3>)> FetchMultipleAsync<T1, T2, T3>(string sql, params object[] args) => throw new NotImplementedException();
public Task<(List<T1>, List<T2>, List<T3>, List<T4>)> FetchMultipleAsync<T1, T2, T3, T4>(string sql, params object[] args) => throw new NotImplementedException();
public Task<(List<T1>, List<T2>)> FetchMultipleAsync<T1, T2>(Sql sql) => throw new NotImplementedException();
public Task<(List<T1>, List<T2>, List<T3>)> FetchMultipleAsync<T1, T2, T3>(Sql sql) => throw new NotImplementedException();
public Task<(List<T1>, List<T2>, List<T3>, List<T4>)> FetchMultipleAsync<T1, T2, T3, T4>(Sql sql) => throw new NotImplementedException();
public void BuildPageQueries<T>(long skip, long take, string sql, ref object[] args, out string sqlCount, out string sqlPage) => throw new NotImplementedException();
}

View File

@@ -17,7 +17,6 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Serilog.Sinks.Console" Version="4.0.0" />
<PackageReference Include="System.Data.SqlClient" Version="4.8.3" />
</ItemGroup>
<ItemGroup>

View File

@@ -5,10 +5,10 @@ using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Diagnostics;
using System.Linq;
using System.Threading;
using Microsoft.Data.SqlClient;
using Microsoft.Extensions.Logging;
using Moq;
using Umbraco.Cms.Core;

View File

@@ -3,10 +3,10 @@
using System;
using System.Collections.Concurrent;
using System.Data.SqlClient;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Data.SqlClient;
using Microsoft.Extensions.Logging;
using Umbraco.Cms.Infrastructure.Persistence;

View File

@@ -4,11 +4,11 @@
using System;
using System.Collections.Generic;
using System.Data.Common;
using System.Data.SqlClient;
using System.IO;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Data.SqlClient;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;

View File

@@ -1,14 +1,13 @@
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Data.SqlClient;
using NPoco;
using NUnit.Framework;
using Umbraco.Cms.Core;
using Umbraco.Cms.Core.Scoping;
using Umbraco.Cms.Infrastructure.Persistence.Dtos;
using Umbraco.Cms.Tests.Common.Testing;
using Umbraco.Cms.Tests.Integration.Testing;

View File

@@ -2,8 +2,8 @@
// See LICENSE for more details.
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using Microsoft.Data.SqlClient;
using Microsoft.Extensions.Logging;
using NUnit.Framework;
using Umbraco.Cms.Core.Cache;

View File

@@ -3,8 +3,8 @@
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using Microsoft.Data.SqlClient;
using Microsoft.Extensions.Logging;
using NUnit.Framework;
using Umbraco.Cms.Core.Cache;

View File

@@ -95,7 +95,6 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Serilog.Sinks.Console" Version="4.0.0" />
<PackageReference Include="System.Data.SqlClient" Version="4.8.3" />
</ItemGroup>
<ItemGroup>

View File

@@ -45,7 +45,7 @@ namespace Umbraco.Cms.Tests.UnitTests.TestHelpers
{
new NullableDateMapper()
};
var pocoDataFactory = new FluentPocoDataFactory((type, iPocoDataFactory) => new PocoDataBuilder(type, pocoMappers).Init());
var pocoDataFactory = new FluentPocoDataFactory((type, iPocoDataFactory) => new PocoDataBuilder(type, pocoMappers).Init(), pocoMappers);
var sqlSyntax = new SqlServerSyntaxProvider(Options.Create(new GlobalSettings()));
SqlContext = new SqlContext(sqlSyntax, DatabaseType.SqlServer2012, pocoDataFactory, factory.GetRequiredService<IMapperCollection>());
Mappers = factory.GetRequiredService<IMapperCollection>();

View File

@@ -6,9 +6,9 @@ using System.Collections.Generic;
using System.ComponentModel;
using System.Data.Odbc;
using System.Data.OleDb;
using System.Data.SqlClient;
using System.Linq;
using System.Reflection;
using Microsoft.Data.SqlClient;
using NUnit.Framework;
using Umbraco.Cms.Core;
using Umbraco.Cms.Core.Composing;

View File

@@ -6,7 +6,7 @@ using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Data;
using System.Data.Common;
using System.Data.SqlClient;
using Microsoft.Data.SqlClient;
using NUnit.Framework;
using Umbraco.Cms.Infrastructure.Persistence;

View File

@@ -42,7 +42,7 @@ namespace Umbraco.Cms.Tests.UnitTests.Umbraco.Infrastructure.Persistence.NPocoTe
public void SqlTemplateArgs()
{
var mappers = new NPoco.MapperCollection { new NullableDateMapper() };
var factory = new FluentPocoDataFactory((type, iPocoDataFactory) => new PocoDataBuilder(type, mappers).Init());
var factory = new FluentPocoDataFactory((type, iPocoDataFactory) => new PocoDataBuilder(type, mappers).Init(), mappers);
var sqlContext = new SqlContext(new SqlServerSyntaxProvider(Options.Create(new GlobalSettings())), DatabaseType.SQLCe, factory);
var sqlTemplates = new SqlTemplates(sqlContext);