From 7bc9751e0a8ffe095c28e10f847e282a18d6482c Mon Sep 17 00:00:00 2001 From: xuejiaming <326308290@qq.com> Date: Fri, 23 Dec 2022 15:15:55 +0800 Subject: [PATCH] 7.x.1.1 --- ShardingCore.sln | 2 +- nuget-publish.bat | 10 ++++---- .../EFCores/EFCore2x/ShardingStateManager.cs | 19 +++++--------- .../EFCores/EFCore3x/ShardingStateManager.cs | 19 +++++--------- .../EFCores/EFCore5x/ShardingStateManager.cs | 19 +++++--------- .../EFCores/EFCore6x/ShardingStateManager.cs | 19 +++++--------- .../EFCores/EFCore7x/ShardingStateManager.cs | 20 ++++++--------- .../Exceptions/ShardingCoreException.cs | 5 +++- .../ShardingCoreNotImplementedException.cs | 25 +++++++++++++++++++ src/ShardingCore/ShardingCore.csproj | 2 +- src2/ShardingCore2/ShardingCore2.csproj | 2 +- src3/ShardingCore3/ShardingCore3.csproj | 2 +- src5/ShardingCore5/ShardingCore5.csproj | 2 +- src6/ShardingCore6/ShardingCore6.csproj | 2 +- .../ShardingCore.Test2x.csproj | 4 ++- 15 files changed, 74 insertions(+), 78 deletions(-) create mode 100644 src/ShardingCore/Exceptions/ShardingCoreNotImplementedException.cs diff --git a/ShardingCore.sln b/ShardingCore.sln index 2481fe62..234b24bb 100644 --- a/ShardingCore.sln +++ b/ShardingCore.sln @@ -55,7 +55,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Sample.ShardingConsole", "s EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Sample.OracleIssue", "samples\Sample.OracleIssue\Sample.OracleIssue.csproj", "{BF4FEA2A-3F09-47D8-9BF7-4261D8D1671D}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ShardingCore.Test6x", "test\ShardingCore.Test6x\ShardingCore.Test6x.csproj", "{8ED3A191-5A29-4599-B383-9FD225CC0BA2}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ShardingCore.Test6x", "test\ShardingCore.Test6x\ShardingCore.Test6x.csproj", "{8ED3A191-5A29-4599-B383-9FD225CC0BA2}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src6", "src6", "{585A790B-8B19-430F-BEB7-9F7D1A3AAFAA}" EndProject diff --git a/nuget-publish.bat b/nuget-publish.bat index fe6c6e7b..6daa4eaa 100644 --- a/nuget-publish.bat +++ b/nuget-publish.bat @@ -1,10 +1,10 @@ :start ::定义版本 -set EFCORE7=7.7.0.9 -set EFCORE6=7.6.0.9 -set EFCORE5=7.5.0.9 -set EFCORE3=7.3.0.9 -set EFCORE2=7.2.0.9 +set EFCORE7=7.7.1.1-preview1 +set EFCORE6=7.6.1.1-preview1 +set EFCORE5=7.5.1.1-preview1 +set EFCORE3=7.3.1.1-preview1 +set EFCORE2=7.2.1.1-preview1 ::删除所有bin与obj下的文件 @echo off diff --git a/src/ShardingCore/EFCores/EFCore2x/ShardingStateManager.cs b/src/ShardingCore/EFCores/EFCore2x/ShardingStateManager.cs index 41dee844..a72555cb 100644 --- a/src/ShardingCore/EFCores/EFCore2x/ShardingStateManager.cs +++ b/src/ShardingCore/EFCores/EFCore2x/ShardingStateManager.cs @@ -9,6 +9,7 @@ using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Internal; using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Storage; +using ShardingCore.Exceptions; using ShardingCore.Sharding.Abstractions; namespace ShardingCore.EFCores @@ -35,34 +36,26 @@ namespace ShardingCore.EFCores public override InternalEntityEntry GetOrCreateEntry(object entity, IEntityType entityType) { var genericDbContext = _currentShardingDbContext.GetShardingExecutor().CreateGenericDbContext(entity); + var findEntityType = genericDbContext.Model.FindEntityType(entity.GetType()); var dbContextDependencies = genericDbContext.GetService(); var stateManager = dbContextDependencies.StateManager; - return stateManager.GetOrCreateEntry(entity,entityType); + return stateManager.GetOrCreateEntry(entity, findEntityType); } public override InternalEntityEntry StartTrackingFromQuery(IEntityType baseEntityType, object entity, in ValueBuffer valueBuffer, ISet handledForeignKeys) { - var genericDbContext = _currentShardingDbContext.GetShardingExecutor().CreateGenericDbContext(entity); - var dbContextDependencies = genericDbContext.GetService(); - var stateManager = dbContextDependencies.StateManager; - return stateManager.StartTrackingFromQuery(baseEntityType, entity, in valueBuffer, handledForeignKeys); + throw new ShardingCoreNotImplementedException(); } public override InternalEntityEntry TryGetEntry(object entity, bool throwOnNonUniqueness = true) { - var genericDbContext = _currentShardingDbContext.GetShardingExecutor().CreateGenericDbContext(entity); - var dbContextDependencies = genericDbContext.GetService(); - var stateManager = dbContextDependencies.StateManager; - return stateManager.TryGetEntry(entity, throwOnNonUniqueness); + throw new ShardingCoreNotImplementedException(); } public override InternalEntityEntry TryGetEntry(object entity, IEntityType entityType) { - var genericDbContext = _currentShardingDbContext.GetShardingExecutor().CreateGenericDbContext(entity); - var dbContextDependencies = genericDbContext.GetService(); - var stateManager = dbContextDependencies.StateManager; - return stateManager.TryGetEntry(entity, entityType); + throw new ShardingCoreNotImplementedException(); } public override int SaveChanges(bool acceptAllChangesOnSuccess) diff --git a/src/ShardingCore/EFCores/EFCore3x/ShardingStateManager.cs b/src/ShardingCore/EFCores/EFCore3x/ShardingStateManager.cs index 7b745e21..72f8c943 100644 --- a/src/ShardingCore/EFCores/EFCore3x/ShardingStateManager.cs +++ b/src/ShardingCore/EFCores/EFCore3x/ShardingStateManager.cs @@ -9,6 +9,7 @@ using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Internal; using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Storage; +using ShardingCore.Exceptions; using ShardingCore.Sharding.Abstractions; namespace ShardingCore.EFCores @@ -35,33 +36,25 @@ namespace ShardingCore.EFCores public override InternalEntityEntry GetOrCreateEntry(object entity, IEntityType entityType) { var genericDbContext = _currentShardingDbContext.GetShardingExecutor().CreateGenericDbContext(entity); + var findEntityType = genericDbContext.Model.FindEntityType(entity.GetType()); var dbContextDependencies = genericDbContext.GetService(); var stateManager = dbContextDependencies.StateManager; - return stateManager.GetOrCreateEntry(entity,entityType); + return stateManager.GetOrCreateEntry(entity, findEntityType); } public override InternalEntityEntry StartTrackingFromQuery(IEntityType baseEntityType, object entity, in ValueBuffer valueBuffer) { - var genericDbContext = _currentShardingDbContext.GetShardingExecutor().CreateGenericDbContext(entity); - var dbContextDependencies = genericDbContext.GetService(); - var stateManager = dbContextDependencies.StateManager; - return stateManager.StartTrackingFromQuery(baseEntityType, entity, in valueBuffer); + throw new ShardingCoreNotImplementedException(); } public override InternalEntityEntry TryGetEntry(object entity, bool throwOnNonUniqueness = true) { - var genericDbContext = _currentShardingDbContext.GetShardingExecutor().CreateGenericDbContext(entity); - var dbContextDependencies = genericDbContext.GetService(); - var stateManager = dbContextDependencies.StateManager; - return stateManager.TryGetEntry(entity, throwOnNonUniqueness); + throw new ShardingCoreNotImplementedException(); } public override InternalEntityEntry TryGetEntry(object entity, IEntityType entityType, bool throwOnTypeMismatch = true) { - var genericDbContext = _currentShardingDbContext.GetShardingExecutor().CreateGenericDbContext(entity); - var dbContextDependencies = genericDbContext.GetService(); - var stateManager = dbContextDependencies.StateManager; - return stateManager.TryGetEntry(entity, entityType, throwOnTypeMismatch); + throw new ShardingCoreNotImplementedException(); } public override int SaveChanges(bool acceptAllChangesOnSuccess) diff --git a/src/ShardingCore/EFCores/EFCore5x/ShardingStateManager.cs b/src/ShardingCore/EFCores/EFCore5x/ShardingStateManager.cs index c2d13098..287a50bb 100644 --- a/src/ShardingCore/EFCores/EFCore5x/ShardingStateManager.cs +++ b/src/ShardingCore/EFCores/EFCore5x/ShardingStateManager.cs @@ -9,6 +9,7 @@ using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Internal; using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Storage; +using ShardingCore.Exceptions; using ShardingCore.Sharding.Abstractions; namespace ShardingCore.EFCores @@ -35,33 +36,25 @@ namespace ShardingCore.EFCores public override InternalEntityEntry GetOrCreateEntry(object entity, IEntityType entityType) { var genericDbContext = _currentShardingDbContext.GetShardingExecutor().CreateGenericDbContext(entity); + var findEntityType = genericDbContext.Model.FindEntityType(entity.GetType()); var dbContextDependencies = genericDbContext.GetService(); var stateManager = dbContextDependencies.StateManager; - return stateManager.GetOrCreateEntry(entity,entityType); + return stateManager.GetOrCreateEntry(entity, findEntityType); } public override InternalEntityEntry StartTrackingFromQuery(IEntityType baseEntityType, object entity, in ValueBuffer valueBuffer) { - var genericDbContext = _currentShardingDbContext.GetShardingExecutor().CreateGenericDbContext(entity); - var dbContextDependencies = genericDbContext.GetService(); - var stateManager = dbContextDependencies.StateManager; - return stateManager.StartTrackingFromQuery(baseEntityType, entity, in valueBuffer); + throw new ShardingCoreNotImplementedException(); } public override InternalEntityEntry TryGetEntry(object entity, bool throwOnNonUniqueness = true) { - var genericDbContext = _currentShardingDbContext.GetShardingExecutor().CreateGenericDbContext(entity); - var dbContextDependencies = genericDbContext.GetService(); - var stateManager = dbContextDependencies.StateManager; - return stateManager.TryGetEntry(entity, throwOnNonUniqueness); + throw new ShardingCoreNotImplementedException(); } public override InternalEntityEntry TryGetEntry(object entity, IEntityType entityType, bool throwOnTypeMismatch = true) { - var genericDbContext = _currentShardingDbContext.GetShardingExecutor().CreateGenericDbContext(entity); - var dbContextDependencies = genericDbContext.GetService(); - var stateManager = dbContextDependencies.StateManager; - return stateManager.TryGetEntry(entity, entityType, throwOnTypeMismatch); + throw new ShardingCoreNotImplementedException(); } public override int SaveChanges(bool acceptAllChangesOnSuccess) diff --git a/src/ShardingCore/EFCores/EFCore6x/ShardingStateManager.cs b/src/ShardingCore/EFCores/EFCore6x/ShardingStateManager.cs index 3f3149e3..87e20090 100644 --- a/src/ShardingCore/EFCores/EFCore6x/ShardingStateManager.cs +++ b/src/ShardingCore/EFCores/EFCore6x/ShardingStateManager.cs @@ -9,6 +9,7 @@ using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Internal; using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Storage; +using ShardingCore.Exceptions; using ShardingCore.Sharding.Abstractions; namespace ShardingCore.EFCores @@ -35,33 +36,25 @@ namespace ShardingCore.EFCores public override InternalEntityEntry GetOrCreateEntry(object entity, IEntityType entityType) { var genericDbContext = _currentShardingDbContext.GetShardingExecutor().CreateGenericDbContext(entity); + var findEntityType = genericDbContext.Model.FindEntityType(entity.GetType()); var dbContextDependencies = genericDbContext.GetService(); var stateManager = dbContextDependencies.StateManager; - return stateManager.GetOrCreateEntry(entity,entityType); + return stateManager.GetOrCreateEntry(entity, findEntityType); } public override InternalEntityEntry StartTrackingFromQuery(IEntityType baseEntityType, object entity, in ValueBuffer valueBuffer) { - var genericDbContext = _currentShardingDbContext.GetShardingExecutor().CreateGenericDbContext(entity); - var dbContextDependencies = genericDbContext.GetService(); - var stateManager = dbContextDependencies.StateManager; - return stateManager.StartTrackingFromQuery(baseEntityType, entity, in valueBuffer); + throw new ShardingCoreNotImplementedException(); } public override InternalEntityEntry TryGetEntry(object entity, bool throwOnNonUniqueness = true) { - var genericDbContext = _currentShardingDbContext.GetShardingExecutor().CreateGenericDbContext(entity); - var dbContextDependencies = genericDbContext.GetService(); - var stateManager = dbContextDependencies.StateManager; - return stateManager.TryGetEntry(entity, throwOnNonUniqueness); + throw new ShardingCoreNotImplementedException(); } public override InternalEntityEntry TryGetEntry(object entity, IEntityType entityType, bool throwOnTypeMismatch = true) { - var genericDbContext = _currentShardingDbContext.GetShardingExecutor().CreateGenericDbContext(entity); - var dbContextDependencies = genericDbContext.GetService(); - var stateManager = dbContextDependencies.StateManager; - return stateManager.TryGetEntry(entity, entityType, throwOnTypeMismatch); + throw new ShardingCoreNotImplementedException(); } public override int SaveChanges(bool acceptAllChangesOnSuccess) diff --git a/src/ShardingCore/EFCores/EFCore7x/ShardingStateManager.cs b/src/ShardingCore/EFCores/EFCore7x/ShardingStateManager.cs index 154d9a8f..6f968cc3 100644 --- a/src/ShardingCore/EFCores/EFCore7x/ShardingStateManager.cs +++ b/src/ShardingCore/EFCores/EFCore7x/ShardingStateManager.cs @@ -1,5 +1,6 @@ #if EFCORE7 +using System; using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; @@ -9,6 +10,7 @@ using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Internal; using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Storage; +using ShardingCore.Exceptions; using ShardingCore.Sharding.Abstractions; namespace ShardingCore.EFCores @@ -33,33 +35,25 @@ namespace ShardingCore.EFCores public override InternalEntityEntry GetOrCreateEntry(object entity, IEntityType entityType) { var genericDbContext = _currentShardingDbContext.GetShardingExecutor().CreateGenericDbContext(entity); + var findEntityType = genericDbContext.Model.FindEntityType(entity.GetType()); var dbContextDependencies = genericDbContext.GetService(); var stateManager = dbContextDependencies.StateManager; - return stateManager.GetOrCreateEntry(entity,entityType); + return stateManager.GetOrCreateEntry(entity, findEntityType); } public override InternalEntityEntry StartTrackingFromQuery(IEntityType baseEntityType, object entity, in ValueBuffer valueBuffer) { - var genericDbContext = _currentShardingDbContext.GetShardingExecutor().CreateGenericDbContext(entity); - var dbContextDependencies = genericDbContext.GetService(); - var stateManager = dbContextDependencies.StateManager; - return stateManager.StartTrackingFromQuery(baseEntityType, entity, in valueBuffer); + throw new ShardingCoreNotImplementedException(); } public override InternalEntityEntry TryGetEntry(object entity, bool throwOnNonUniqueness = true) { - var genericDbContext = _currentShardingDbContext.GetShardingExecutor().CreateGenericDbContext(entity); - var dbContextDependencies = genericDbContext.GetService(); - var stateManager = dbContextDependencies.StateManager; - return stateManager.TryGetEntry(entity, throwOnNonUniqueness); + throw new ShardingCoreNotImplementedException(); } public override InternalEntityEntry TryGetEntry(object entity, IEntityType entityType, bool throwOnTypeMismatch = true) { - var genericDbContext = _currentShardingDbContext.GetShardingExecutor().CreateGenericDbContext(entity); - var dbContextDependencies = genericDbContext.GetService(); - var stateManager = dbContextDependencies.StateManager; - return stateManager.TryGetEntry(entity, entityType, throwOnTypeMismatch); + throw new ShardingCoreNotImplementedException(); } public override int SaveChanges(bool acceptAllChangesOnSuccess) diff --git a/src/ShardingCore/Exceptions/ShardingCoreException.cs b/src/ShardingCore/Exceptions/ShardingCoreException.cs index 44a2c4b9..7f67c2c5 100644 --- a/src/ShardingCore/Exceptions/ShardingCoreException.cs +++ b/src/ShardingCore/Exceptions/ShardingCoreException.cs @@ -16,7 +16,10 @@ namespace ShardingCore.Exceptions [ExcludeFromCodeCoverage] public class ShardingCoreException : Exception { - + public ShardingCoreException() + { + + } public ShardingCoreException(string message) : base(message) { } diff --git a/src/ShardingCore/Exceptions/ShardingCoreNotImplementedException.cs b/src/ShardingCore/Exceptions/ShardingCoreNotImplementedException.cs new file mode 100644 index 00000000..0ea43e0d --- /dev/null +++ b/src/ShardingCore/Exceptions/ShardingCoreNotImplementedException.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ShardingCore.Exceptions +{ + [ExcludeFromCodeCoverage] + public class ShardingCoreNotImplementedException:ShardingCoreException + { + public ShardingCoreNotImplementedException() + { + + } + public ShardingCoreNotImplementedException(string message) : base(message) + { + } + + public ShardingCoreNotImplementedException(string message, Exception innerException) : base(message, innerException) + { + } + } +} diff --git a/src/ShardingCore/ShardingCore.csproj b/src/ShardingCore/ShardingCore.csproj index 967d686a..7841de39 100644 --- a/src/ShardingCore/ShardingCore.csproj +++ b/src/ShardingCore/ShardingCore.csproj @@ -1,7 +1,7 @@  net6.0 - 7.7.0.11 + $(EFCORE7) true TRACE;DEBUG;EFCORE7; latest diff --git a/src2/ShardingCore2/ShardingCore2.csproj b/src2/ShardingCore2/ShardingCore2.csproj index 12b523ac..9991f715 100644 --- a/src2/ShardingCore2/ShardingCore2.csproj +++ b/src2/ShardingCore2/ShardingCore2.csproj @@ -2,7 +2,7 @@ netstandard2.0 - 7.2.0.11 + $(EFCORE2) true TRACE;DEBUG;EFCORE2; 9.0 diff --git a/src3/ShardingCore3/ShardingCore3.csproj b/src3/ShardingCore3/ShardingCore3.csproj index d7d0da04..7bfb0be2 100644 --- a/src3/ShardingCore3/ShardingCore3.csproj +++ b/src3/ShardingCore3/ShardingCore3.csproj @@ -1,7 +1,7 @@  netstandard2.0 - 7.3.0.11 + $(EFCORE3) true TRACE;DEBUG;EFCORE3; 9.0 diff --git a/src5/ShardingCore5/ShardingCore5.csproj b/src5/ShardingCore5/ShardingCore5.csproj index 84209a90..3c222f1a 100644 --- a/src5/ShardingCore5/ShardingCore5.csproj +++ b/src5/ShardingCore5/ShardingCore5.csproj @@ -2,7 +2,7 @@ netstandard2.1 - 7.5.0.11 + $(EFCORE5) true TRACE;DEBUG;EFCORE5; 9.0 diff --git a/src6/ShardingCore6/ShardingCore6.csproj b/src6/ShardingCore6/ShardingCore6.csproj index 5d770f9d..63a12978 100644 --- a/src6/ShardingCore6/ShardingCore6.csproj +++ b/src6/ShardingCore6/ShardingCore6.csproj @@ -2,7 +2,7 @@ net6.0 - 7.6.0.11 + $(EFCORE6) true TRACE;DEBUG;EFCORE6; 9.0 diff --git a/test/ShardingCore.Test2x/ShardingCore.Test2x.csproj b/test/ShardingCore.Test2x/ShardingCore.Test2x.csproj index f64d8834..eda65ee7 100644 --- a/test/ShardingCore.Test2x/ShardingCore.Test2x.csproj +++ b/test/ShardingCore.Test2x/ShardingCore.Test2x.csproj @@ -1,10 +1,12 @@  - netcoreapp2.2 + netcoreapp3.1 9.0 + +